PHP: preg_replace all occurrences in string withing defined delimeters
Actually I trinig to replace all "a" with "b" inisde some string. Problem
is that I need to replace only those latters which is inside brackets:
asd asd asd [asd asd asd] asd asd asd
For now I have next code for this:
$what = '/(?<=\[)a(?=.*?\])/s';
$with = 'b';
$where = 'asd asd asd [asd asd asd] asd asd asd';
But it only replace first "a", and I getting next string:
asd asd asd [bsd asd asd] asd asd asd
I realy need to done this only with one preg_replace call.
No comments:
Post a Comment