我想要time
单词的正则表达式和[]{}^
字符串中不允许的那些字符串格式。
喜欢,
testtime -> allowed
tim etest -> allowed
thetimetest -> allowed
the time test -> not allowed
test[my -> not allowed
my}test -> not allowed
test^time -> not allowed
我针对字符串中不允许的单词开发了以下正则表达式。但是他们不能检查是否区分大小写c#
。
^((?!Time)[^[\]{}])*$
您可以像这样使用否定的前瞻:
^(?!.*time)[^.]*$
编辑:根据更新,您可以使用此正则表达式:
^(?!.*\btime\b)[^.^\[\]{}]*$
至于不区分大小写,您可以使用标志RegexOptions.IgnoreCase
或(?i)
在正则表达式中使用,例如(?i)^(?!.*\btime\b)[^.^\[\]{}]*$
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句