input with the all
of the matches (if any) replaced. If no match is found returns the input string itself.
R replaceAll(R, C, RegEx)(R input, RegEx re, const(C)[] format) if (isSomeString!R && is(C : dchar) && isRegexFor!(RegEx, R)) @trustedConstruct a new string from input by replacing all of the fragments that match a pattern re with a string generated from the match according to the format specifier.
To replace only the first match use replaceFirst.
input | string to search |
re | compiled regular expression to use |
format | _format string to generate replacements from, see Replace _format string, the _format string. |
input with the all
of the matches (if any) replaced. If no match is found returns the input string itself.
R replaceAll(alias fun, R, RegEx)(R input, RegEx re) if (isSomeString!R && isRegexFor!(RegEx, R)) @trustedThis is a general replacement tool that construct a new string by replacing matches of pattern re in the input. Unlike the other overload there is no format string instead captures are passed to to a user-defined functor fun that returns a new string to use as replacement.
This version replaces all of the matches found in input, see replaceFirst to replace the first match only.
input with all matches
replaced by return values of fun. If no matches found returns the input itself.
input | string to search |
re | compiled regular expression |
fun | delegate to use |