preg_replace issue
Hi, a small issue with regular expressions:
My result should contain only unicode alphabets and ()[]{}+-_,:&!?@#$£=;~/"'.
Here is my trial
$result = preg_replace( '/^[^\pL-0-9- "\',()\[\]{}*\/+\-_,.:&!?@#$£=*;~]*$/', ' ', $string)
Seems that < and > are not removed from $string... what am I missing?
Thanks already!
The dot is not escaped so it equals any character including <and >
$result = preg_replace( '/^[^\pL-0-9- "\',()\[\]{}*\/+\-_,\.:&!?@#$£=*;~]*$/', ' ', $string);
Should work better.
You can always check your regexp on https://regexr.com/
@TRAY2 - Can't get it to work with this either...
using >string< as $string returns >string<
Also, regexer doesn't understand \pL. Any ideas for that?
This seems to do the trick
preg_replace('/[^\pL-0-9- "\',()\[\]{}*\/+,.:&!?@&#$£=*;~]/u', ' ', $string);
Prove me wrong =)
Please or to participate in this conversation.