0
我使用正则表达式如下检查其它输入点儿然后允许的字符...(A-ZA-Z0-9点,逗号,破折号和singlequote和BR标签)如何翻转正则表达式?
<?php
$regex_char_appearance = '/([A-Za-z0-9 \-\.\,\']|(<br>))/';
?>
我一直在试图创建一个正则表达式来清理用户输入。我只是无法得到它的工作,所以尝试不同的东西像...
<?php
$regex_char_appearance = '/(?!<br>)([^A-Za-z0-9 \-\.\,\'])/';
$regex_char_appearance = '/([^A-Za-z0-9 \-\.\,\']|[^(<br>)])/';
//remove anything other then alphabetic and allowed
$post_char_appearance = preg_replace($regex_char_appearance , '' , $post_char_appearance);
?>
所以目标是消除任何其他然后-ZA-Z0-9,点,逗号,破折号,singlequote和用preg_replace输出的br标签。
有人可以帮我把一个正则表达式合在一起吗?
我想'[^ A-Za-z0-9。,' - ]'应该足够*除去a-zA - ** Z ** 0-9之外的任何东西,点,逗号,短划线和单引号*要求。什么是'
'在这里做什么?你想要匹配“
”以外的其他任何东西吗? –
我的坏....并且
也被允许......但不是< or >。 –
好吧,''〜[^ A-Za-z0-9。,' - ]〜''应该可以工作。不是吗? –