I know next to nothing about RegEx, even after reading a few tutorials :\ I basically just want to know how to replace tags with tags – so how do you match the tag and how do you state that you want to replace it, keeping the tag text as it is? I saw something about a $1 in the replacement string but I don’t know what that refers to?
Be as in-depth as you can, I’m brand new to this and need help!
Here is the very simple example:
In this example regular expression matches opening B tag content within tag and closing B tag. Following pattern (.*?) groups content separately so you can later refer to it like $1.
If we modify expression slightly by adding more grouping parenthesis:
Replacement part will change from $1 to $2, as far as we have three groups we are referring to (.*?) with $2 as it’s a second group etc…
http://www.php.net/manual/en/reference.pcre.pattern.syntax.php