XF 2.1 Regex, but not in URL

Robert9

Well-known member
At the moment i play with that

$newMessage = preg_replace("/([\w])( , | ,|,)([\w])/", "$1, $3", $newMessage);

It should change

hi,Baby!
hi , Baby!
hi ,Baby!

to
hi, Baby!

Now i would like to do the same with ".", but here i have the problem with urls;
i have no idea how to stop the regex inside url]...[/url
 
While technically possible, this is a pretty nasty task to achieve with a regex on the entire message. You'd have to work with lookaheads and lookbehinds.
 
Back
Top Bottom