You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VerbalExpressions is a Haxe library that helps to construct difficult regular expressions. Ported from the awesome JavaScript VerbalExpressions.
This project wraps around the Haxe EReg class.
Getting started
Clone the project or download the sources.
Basic usage of Verbal Expressions is trough new expressions.VerbalExpression():
varexpression=newexpressions.VerbalExpression()
.startOfLine()
.then("http")
.maybe("s")
.then("://")
.maybe("www.")
.anythingBut("")
.endOfLine();
varurl="https://www.haxe.org/";
// test if the url matchesif (expression.isMatch(url)) {
trace('$url is a valid URL');
} else {
trace('$url is an invalid URL');
}
trace(expression.toString());
// logs the regular expression source: ^(http)(s)?(://)(www.)?([^{ }]*)$expression.toRegex();
// the Haxe EReg instance
Replacing strings
varresult:String=newexpressions.VerbalExpression()
.find("bird")
.replace("Replace bird with a duck", "duck");
trace(result);
// logs "Replace duck with a duck"
Dependencies
This project has no external dependencies.
Status
Haxe target
status
Haxe interpreter
works
C++
works
C#
works
Java
compiles but has errors
JavaScript
works
Neko
works
PHP
works
Python
works
Flash
works
Note: Haxe is awesome! One codebase, many targets, no platform specific code.
API documentation
You can find the documentation for the original JavaScript repo on their wiki. There can be some differences in the methods, but in general this documentation will cover most functions.
Contributions
Clone the repo and fork! Pull requests are welcome.
Credits
Thank you to @jehna for coming up with the awesome original idea!