PHP re-expression to remove multiple? -signs

Am I having trouble with the correct regex string to remove a sequence from multiple? characters. I want to replace several consecutive? with one ?, but which characters run away ... eludes me.

Input Example:

Is it on ??? or what ???

Required Conclusion:

What is this thing for? or what?

I am using preg_replace () in PHP.

+5
source share
7 answers
preg_replace('{\?+}', '?', 'Is this thing on??? or what???');

, "\? +" , , , "\? {2,}" ( .

+9

preg_replace( '{\\?+}', '?', $text );

.

, .

, # verbatim strings .

+2

( ):

preg_replace('/\?+/', '?', $subject);
+1
preg_replace('/\?{2,}/','?',$text)
+1

preg_replace('/(\?+)/m', '?', 'what is going in here????');

, m - .

-, http://regex.larsolavtorvik.com/

+1

[?]+

??

0
str_replace('??', '?', 'Replace ??? in this text');
0

All Articles