Method ExtString.RxReplace(+ 3 overloads)
Overload
Finds and replaces all match instances of PCRE regular expression rx.
public static string RxReplace(this string t, string rx, string repl, int maxCount = -1, RXFlags flags = 0, Range? range = null)
Parameters
|
t (string)
This string. |
|
rx (string)
Regular expression. Cannot be |
|
repl (string)
Replacement pattern.
Can consist of any combination of literal text and substitutions like |
|
maxCount (int)
Maximal count of replacements to make. If -1 (default), replaces all. |
|
flags (RXFlags)
Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF. |
|
range (Range?)
Start and end offsets in the subject string. If |
Returns
|
string
The result string. |
Exceptions
|
ArgumentOutOfRangeException
Invalid range. |
ArgumentException
|
|
AuException
Failed (unlikely). |
|
ArgumentNullException
s is |
Remarks
More info and examples: regexp.
Overload(next)
Finds and replaces all match instances of PCRE regular expression rx.
public static int RxReplace(this string t, string rx, string repl, out string result, int maxCount = -1, RXFlags flags = 0, Range? range = null)
Parameters
|
t (string)
This string. |
|
rx (string)
Regular expression. Cannot be |
|
repl (string)
Replacement pattern.
Can consist of any combination of literal text and substitutions like |
|
result (string)
The result string. Can be the same variable as the subject string. |
|
maxCount (int)
Maximal count of replacements to make. If -1 (default), replaces all. |
|
flags (RXFlags)
Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF. |
|
range (Range?)
Start and end offsets in the subject string. If |
Returns
|
int
The number of replacements made. Returns the result string through an out parameter. |
Exceptions
|
ArgumentOutOfRangeException
Invalid range. |
ArgumentException
|
|
AuException
Failed (unlikely). |
|
ArgumentNullException
s is |
Remarks
More info and examples: regexp.
Overload(next)
Finds and replaces all match instances of PCRE regular expression rx. Uses a callback function.
public static string RxReplace(this string t, string rx, Func<RXMatch, string> replFunc, int maxCount = -1, RXFlags flags = 0, Range? range = null)
Parameters
|
t (string)
This string. |
|
rx (string)
Regular expression. Cannot be |
|
replFunc (Func<RXMatch, string>)
Callback function's delegate, eg lambda. Called for each found match. Returns the replacement. In the callback function you can use RXMatch.ExpandReplacement. |
|
maxCount (int)
Maximal count of replacements to make. If -1 (default), replaces all. |
|
flags (RXFlags)
Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF. |
|
range (Range?)
Start and end offsets in the subject string. If |
Returns
|
string
The result string. |
Exceptions
|
ArgumentOutOfRangeException
Invalid range. |
ArgumentException
|
|
AuException
Failed (unlikely). |
|
ArgumentNullException
s is |
Remarks
More info and examples: regexp.
Overload(top)
Finds and replaces all match instances of PCRE regular expression rx. Uses a callback function.
public static int RxReplace(this string t, string rx, Func<RXMatch, string> replFunc, out string result, int maxCount = -1, RXFlags flags = 0, Range? range = null)
Parameters
|
t (string)
This string. |
|
rx (string)
Regular expression. Cannot be |
|
replFunc (Func<RXMatch, string>)
Callback function's delegate, eg lambda. Called for each found match. Returns the replacement. In the callback function you can use RXMatch.ExpandReplacement. |
|
result (string)
The result string. Can be the same variable as the subject string. |
|
maxCount (int)
Maximal count of replacements to make. If -1 (default), replaces all. |
|
flags (RXFlags)
Options. Default 0. Flag UTF is implicitly added if rx contains non-ASCII characters and there is no flag NEVER_UTF. |
|
range (Range?)
Start and end offsets in the subject string. If |
Returns
|
int
The number of replacements made. Returns the result string through an out parameter. |
Exceptions
|
ArgumentOutOfRangeException
Invalid range. |
ArgumentException
|
|
AuException
Failed (unlikely). |
|
ArgumentNullException
s is |
Remarks
More info and examples: regexp.