I run an open source project which is hosted on github. I'm currently about to release a new version which is running on PHP 7. This is where I'm needing help. I'm fairly strong with majority of PHP functions and equally comfortable with mysqli
but in all my time running my project I've never worked with regex. I have two patterns with the now defunct /e
modifier in use and have no idea how to fix them, so I'm hoping by asking the question here to actually learn something and also fix my problems.
Problem one is coming from one preg_replace
I used for Geshi syntax highlighter for code tag.
// [php]code[/php]
if (stripos($s, '[php]') !== false) {
$s = preg_replace("#\[(php|sql|html)\](.+?)\[\/\\1\]#ise", "source_highlighter('\\2','\\1')", $s);
}
The second one handles media tags like liveleak etc:
if (stripos($s, '[media=') !== false) {
$s = preg_replace("#\[media=(youtube|liveleak|GameTrailers|vimeo|imdb)\](.+?)\[/media\]#ies", "_MediaTag('\\2','\\1')", $s);
}
Both are not working and throwing this error:
PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead.
Trouble is I have no idea how to work with regex, I've tried using tutorials over the past few weeks and still don't really understand it, any help would be really appreciated.