Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex mvc3正则表达式块字_Regex_Asp.net Mvc 3_Filter - Fatal编程技术网

Regex mvc3正则表达式块字

Regex mvc3正则表达式块字,regex,asp.net-mvc-3,filter,Regex,Asp.net Mvc 3,Filter,我有一个MVC3模型和一个文本框,可以接受一些html。它工作得很好,但是我如何过滤www和色情这两个词呢?因为有些人一直在写,我的模型是 [AllowHtml] [RegularExpression(@"^([^<]|<em>|</em>|<u>|</u>||a z|A Z|1 9|)*$", ErrorMessage = "Invalid character")] public string mytextbox {

我有一个MVC3模型和一个文本框,可以接受一些html。它工作得很好,但是我如何过滤www色情这两个词呢?因为有些人一直在写,我的模型是

   [AllowHtml]
    [RegularExpression(@"^([^<]|<em>|</em>|<u>|</u>||a z|A Z|1 9|)*$", ErrorMessage = "Invalid character")]

    public string mytextbox { get; set; }
[allowtml]

[RegularExpression(@“^([^您可以使用负前瞻,如:

^(?!.*(?:www|porn))(?:[^<>]|<em>|</em>|<u>|</u>)*\z
^(?。*(?:www | porn))(?:[^]| | | |)*\z
表达式的其余部分没有用,所以我删除了它。请注意,在进行这样的过滤时,必须正确编码。可能还有其他方法

它还将匹配任何包含
www
porn
的单词。如果不需要,可以添加一些
\b
s