Specifying limits is done to relieve you from brain strain - so you can immediately recognize author's intentions.
All occurrences -
Limited occurrences -
Read on to learn more about replacing with a callback.
Regular expression references
Normally, had you passed a replacement to
preg_replace(), that contains a backslash or a dollar sign followed by a
$2) - that reference would be replaced by a corresponding capturing group (or by an empty string,
if the group wasn't matched).
Resolving such references won't happen with T-Regx.
This is done to relieve you from the brain strain. A programmer should be able to merely
replace a string with a constant value without [cognitive load] about possible
$ hiding somewhere.
You can be sure, what's put into
with() will certainly be present unchanged in your final result.
Some replacement strings containing a backslash or a dollar sign (like file system paths, URL addresses or even user input) might interfere with logic and cause bugs that are very hard to find.
Neither of types of references are resolved:
If you, however, would like to intentionally use regular expression references and have validated your input
against an unexpected
$ - feel free to use
withReferences() which will resolve replacement references.