verdy_p
Member since Dec 28, 2009
- Profile: /members/5050-verdy-p.htm
- URL: http://about steve comment:
- Comments: 3
Recent Blog Comments By verdy_p
-
Javascript Exec() Method For Regular Expression Matching
Posted on Dec 28, 2009 at 2:22 AM
Sorry, replace: for var re = /\t/g, match = re.exec(string); match != null; match = re.exec(match.source)) { ...// use the match[0] substring which maps to match.source at position match.index } by: for (var re = /\t/g, match = re.exec(string); match != null; match = re.exec(match.input)) { ...//... read more »
-
Javascript Exec() Method For Regular Expression Matching
Posted on Dec 28, 2009 at 1:59 AM
Note also: if the "g" flag is specified, this is the only case where at most one match will be returned in the non-null array (the loop is then needed) and the regexp object will be modified to hold the lastIndex. In that case also, the returned non-null array (match above) will not just be an array... read more »
-
Javascript Exec() Method For Regular Expression Matching
Posted on Dec 28, 2009 at 12:59 AM
NEVER use the code: while (match = /\t/g.exec(string)) { ...// use match[] array... } which effectively can recompile the regexp at each iteration (the /\t/g syntax is considered in IE as the equivalent of instanciating a new Regexp with the string "\\t" and the flag "g", as if you had effectively... read more »