EReg

class ERegAvailable in flash8, flash, neko, js, php, cppRegular expression is a way to find regular patterns into Strings.
Have a look a Using Regular Expressions to learn how to use them.
EReg example: Email Validation (cross platform)
function new( r : String, opt : String ) : VoidCreates a new regular expression with pattern r and options opt. function customReplace( s : String, f : EReg -> String ) : StringFor 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 ) : BoolTells if the regular expression matches the String. Updates the internal state accordingly. function matched( n : Int ) : StringReturns a matched group or throw an expection if there is no such group. If n = 0, the whole matched substring is returned. function matchedLeft() : StringReturns the part of the string that was as the left of the matched substring. function matchedPos() : { pos : Int, len : Int }Returns the position of the matched substring within the original matched string. function matchedRight() : StringReturns the part of the string that was as the right of of the matched substring. function replace( s : String, by : String ) : StringReplaces 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.
version #13551, modified 2012-04-12 22:32:42 by api

0 Comments