Answer the question
In order to leave comments, you need to log in
How to prevent a user from writing contact information in a comment?
I mean some kind of ready-made solution / extension for puff or yii, so as not to write regular expressions. Block the spelling of the phone 8999... 8-999... 8 9 9 9, etc., cart, mail, etc.
Answer the question
In order to leave comments, you need to log in
function removeEmailAndPhoneFromString($string) {
// remove email
$string = preg_replace('/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/','',$string);
// remove phone
$string = preg_replace('/([0-9]+[\- ]?[0-9]+)/','',$string);
return $string;
}
// Привет, это я. Мой номер +, напиши мне на
echo removeEmailAndPhoneFromString('Привет, это я. Мой номер +375442381342, напиши мне на [email protected]');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question