Reputation: 3132
I'm trying to figure out a regex (in PHP) to find
<ANYTHING_BUT_WHITSPACE>? OR ?<ANYTHING_BUT_WHITSPACE>
and replace the ? with a blank space. So, '?test test?' should become 'test test'. I have one working in java
"(?<=\\S)\\" + "?" + "|\\" + "?" + "(?=\\S)"
Any idea what it would be in PHP?
Upvotes: 0
Views: 64
Reputation: 78994
There is probably a better pattern but almost the same:
echo preg_replace('/(?<=\S)\?|\?(?=\S)/', '$1', '?test test?');
/
+
use .
but not needed\\
Upvotes: 1