Php: preg replace one question mark?
3 answers
If you wanted not to replace the question mark in the string testing ??
, you could do:
// using negative lookbehind/ahead to ensure that the question mark
// doesn't have a "friend"
$new = preg_replace('/(?<!\?)\?(?!\?)/', 'replacement', $original);
If you only want to replace the first question mark in the line - chaos request is what you want
0
source to share