| Extracted from Pike v7.8 release 866 at 2016-04-05.

[Top]
Regexp
Regexp.PCRE
Regexp.PCRE._Regexp_PCRE
Regexp.PCRE._Regexp_PCRE.Plain

# Method Regexp.PCRE._Regexp_PCRE.Plain()->replace()

Method replace

  `string replace(string subject, string|function with, mixed|void ... args)`

Description

  replace all occurances of a pattern in a subject; callbacks and replacements will be from the first occurance, not from the last as in Regexp.Builtin.replace.

  if with is a function, the first argument will be the total match string, and the subsequent arguments will contain any submatches

  example: > Regexp.PCRE("b[^-]*m")->replace("abam-boom-fooabadoom","gurka"); Result: "agurka-gurka-fooagurka" > Regexp.PCRE("b[^-]*m")->replace("abam-boom-fooabadoom", lambda(string s) { werror("%O\n",s); return "gurka"; }); "bam" "boom" "badoom" Result: "agurka-gurka-fooagurka"

  example:

  > Regexp.PCRE("([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})") ->replace("foo@bar.org", lambda(string whole, string user, string loc, string domain) { return user + " from " + loc + " dot " + domain; } ); (4) Result: "foo from bar dot org"