I need a simple regexp for php preg_replace:
Input: Quick brown :no: fox etc Output: Quick brown !|no|! fox etc
:something: to !|something|!
I need a simple regexp for php preg_replace:
Input: Quick brown :no: fox etc Output: Quick brown !|no|! fox etc
:something: to !|something|!
$output = preg_replace('/:([^ ]+):/', '!|$1|!', $input);
You might want to replace [^ ]
with a more specific set, depending on what you are expecting to be in between the :
s.