haXe API Documentation
Back | Index
class EReg
Available in flash, neko, js, flash9, php, cpp
Regular expressions are a way to find regular patterns into Strings. Have a look at the tutorial on haXe website to learn how to use them.
function new(r : String, opt : String) : Void
Available in flash
Creates a new regular expression with pattern r and options opt.
function new(r : String, opt : String) : Void
Available in neko, js, flash9, php, cpp
function customReplace(s : String, f : EReg -> String) : String
For each occurence of the pattern in the string s, the function f is called and can return the string that needs to be replaced. All occurences are matched anyway, and setting the g flag might cause some incorrect behavior on some platforms.
function match(s : String) : Bool
Tells if the regular expression matches the String. Updates the internal state accordingly.
function matched(n : Int) : String
Returns a matched group or throw an expection if there is no such group. If n = 0, the whole matched substring is returned.
function matchedLeft() : String
Returns the part of the string that was as the left of of the matched substring.
function matchedPos() : { pos : Int, len : Int}
Returns the position of the matched substring within the original matched string.
function matchedRight() : String
Returns the part of the string that was at the right of of the matched substring.
function replace(s : String, by : String) : String
Replaces a pattern by another string. The by format can contains $1 to $9 that will correspond to groups matched while replacing. $$ means the $ character.
function split(s : String) : Array<String>
Split a string by using the regular expression to match the separators.
Back | Index