Answer the question
In order to leave comments, you need to log in
How to do regular expression substitution?
Hello.
I need to do a regular expression replacement, I do it like this:
preg_replace('/{{(.+)}}/', substr('$1', 0, -5), $text);
Answer the question
In order to leave comments, you need to log in
$text = preg_replace_callback('/{{(.+)}}/', function ($value) {
return substr($value[1], 0, -5);
}, $text);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question