I need help making a preg_replace() command to replace some stuff on my webpage.
I've got a text like this:
"click !:here:! to get some info about some stuff";
and another variable, with the URL for a link, that will change often. So I want to use preg_replace to replace the !: and the :! with <a> and </a> tags.
so the regexp, I don't really know if that's any good at all. It's just something I think might be correct. The thing is that the link could be anywhere in the string $infotext, and with any chars between the !: and the :!.. possible that I might want to change the symbols !: and :! too. I'm not really good at REGEXP.
the $text variable shall be taken from the regexp search-pattern. Because the text between !: and :! will change quite often too.
Hope this is possible.
Cheers,
Artheus
Last edited by artheus; 02-08-2010 at 03:18 AM.
Reason: some mistakes
If you have more than one placeholder your regex is going to match from the start of the first to end of the last. If this is an issue you will want to make the expression non-greedy - and maybe you would want to make it case insensitive too?
Bookmarks