Let's assume I use the following php function:
preg_replace($search, $replace, $str);
I'm only able to modify the search and replace var. Is it possible to do the following replace:
test -> test test2
And
test 3 -> test3
I tried the following:
$search = '/test (?=*)/';
$replace = 'test($1)';
This works for the second case. But now I want to use a if, in order to say "if $1 is empty, add test2. But I'm only able to modify the search and replace var without using addition php. Is this even possible in regex?