T
Theo Chakkapark
I'm having issues trying to replace text with PHP.
For example, if I have a string of text that reads:
{tag}
And want to replace that with:
$_POST["var"]
I get the following result:
{tag}POST["var"]
The $_ seems to be replaced with the original text. The problem is, I
cannot seem to escape $_ at the same time. The text is stored in an
array. For example, I have two arrays, one with the text to find,
another with the text to replace. The arrays are loaded dynamically
from a text file that defines these find/replace tags. The following
did not work:
Regex.Replace(text, Regex.Escape(@arrlstModuleFind.ToString()),
Regex.Escape(@arrlstModuleReplace.ToString()),
RegexOptions.IgnoreCase);
Also, adding slashes to the replacement text does not work either,
such as \$_.
Any tips?
For example, if I have a string of text that reads:
{tag}
And want to replace that with:
$_POST["var"]
I get the following result:
{tag}POST["var"]
The $_ seems to be replaced with the original text. The problem is, I
cannot seem to escape $_ at the same time. The text is stored in an
array. For example, I have two arrays, one with the text to find,
another with the text to replace. The arrays are loaded dynamically
from a text file that defines these find/replace tags. The following
did not work:
Regex.Replace(text, Regex.Escape(@arrlstModuleFind.ToString()),
Regex.Escape(@arrlstModuleReplace.ToString()),
RegexOptions.IgnoreCase);
Also, adding slashes to the replacement text does not work either,
such as \$_.
Any tips?