Answer the question
In order to leave comments, you need to log in
Why does the regular expression remove the letter B?
Actually I'm trying to remove extra characters from a string with such a regular expression:
preg_replace('/([:^~|@№$–=+*&%;\[\]<>()_—«»#\/]+)/i', "", $some);
Answer the question
In order to leave comments, you need to log in
i checked the theory about the "unescaped hyphen"
if a hyphen is used in this place, _-«
then the regular expression haws like all characters from _ до «
if you look at the unicode character code "Underscore" _
, we will see that it has a U+005F
serial number = 95
and "quotation mark", in its own turn U+00AB
= 171
all Latin letters in lower case fall into this range,
and since you still have the "i" flag in the regular expression - case insensitivity, then this regular expression also includes Latin letters in Upper case
https://repl.it/ repls/SpryAzureAudit
No B is removed.
Added only /u for correct work with utf-8.
var_dump(preg_replace('/([:^~|@№$–=+*&%;\[\]<>()_—«»#\/]+)/iu', "", "Владимир владимирович #$#[email protected]%"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question