EReg

class ERegAvailable in flash8, flash, neko, js, php, cpp, cs, javaRegular 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 ) : VoidAvailable in cs, javaCreates a new regular expression with pattern r and options opt. function new( r : String, opt : String ) : VoidAvailable in flash8, flash, neko, js, php, cppCreates a new regular expression with pattern r and options opt. function map( s : String, f : EReg -> String ) : StringAvailable in cs, java function map( s : String, f : EReg -> String ) : StringAvailable in flash8, flash, neko, js, php, cpp function match( s : String ) : BoolAvailable in cs, javaTells if the regular expression matches the String. Updates the internal state accordingly. function match( s : String ) : BoolAvailable in flash8, flash, neko, js, php, cppTells if the regular expression matches the String. Updates the internal state accordingly. function matchSub( s : String, pos : Int, ?len : Int ) : BoolAvailable in cs, java function matchSub( s : String, pos : Int, ?len : Int ) : BoolAvailable in flash8, flash, neko, js, php, cpp function matched( n : Int ) : StringAvailable in cs, javaReturns a matched group or throw an exception if there is no such group. If n = 0, the whole matched substring is returned. function matched( n : Int ) : StringAvailable in flash8, flash, neko, js, php, cppReturns a matched group or throw an exception if there is no such group. If n = 0, the whole matched substring is returned. function matchedLeft() : StringAvailable in cs, javaReturns the part of the string to the left of the matched substring. function matchedLeft() : StringAvailable in flash8, flash, neko, js, php, cppReturns the part of the string to the left of the matched substring. function matchedPos() : { pos : Int, len : Int }Available in cs, javaReturns the position of the matched substring within the original matched string. function matchedPos() : { pos : Int, len : Int }Available in flash8, flash, neko, js, php, cppReturns the position of the matched substring within the original matched string. function matchedRight() : StringAvailable in cs, javaReturns the part of the string to the right of of the matched substring. function matchedRight() : StringAvailable in flash8, flash, neko, js, php, cppReturns the part of the string to the right of of the matched substring. function replace( s : String, by : String ) : StringAvailable in cs, javaReplaces 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 replace( s : String, by : String ) : StringAvailable in flash8, flash, neko, js, php, cppReplaces 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>Available in cs, javaSplit a string by using the regular expression to match the separators. function split( s : String ) : Array<String>Available in flash8, flash, neko, js, php, cppSplit a string by using the regular expression to match the separators.
version #19308, modified 2013-05-08 11:13:10 by api
1 comment
  • May 01, 2013 at 01:01

    matchedPos throws an exception if the EReg hasn't yet been executed on a string