Skip to content

Commit

Permalink
Remove generic implementation for EReg.map and fix misleading documen…
Browse files Browse the repository at this point in the history
…tation.

Every platform implementation handles the "global" flag.
  • Loading branch information
nadako committed Nov 17, 2013
1 parent 1cbeb81 commit 90e8293
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions std/EReg.hx
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,20 @@ class EReg {
}

/**
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.
Calls the function `f` for the substring of `s` which `this` EReg matches
and replaces that substring with the result of `f` call.
The `f` function takes `this` EReg object as its first argument and should
return a replacement string for the substring matched.
If `this` EReg does not match any substring, the result is `s`.
By default, this method replaces only the first matched substring. If
the global g modifier is in place, all matched substrings are replaced.
If `s` or `f` are null, the result is unspecified.
**/
public function map( s : String, f : EReg -> String ) : String {
var buf = new StringBuf();
while( true ) {
if( !match(s) )
break;
buf.add(matchedLeft());
buf.add(f(this));
s = matchedRight();
}
buf.add(s);
return buf.toString();
return null;
}
}

0 comments on commit 90e8293

Please sign in to comment.