I need a regex to match if anywhere in a sentence there is NOT either < or >.
If either < or > are in the string then it must return false.
I had a partial success with this but only if my < > are at the beginning or end:
(?!<|>).*$
I am using .Net if that makes a difference.
Thanks for the help.
^[^<>]+$
字符类中的插入符号( [^
]表示匹配任何内容,但这意味着,字符串的开头,然后是除<
和>
之外的任何内容中的一个或多个,然后是字符串的结尾。
Here you go:
^[^<>]*$
This will test for string that has no <
and no >
If you want to test for a string that may have <
and >
, but must also have something other you should use just
[^<>] (or ^.*[^<>].*$)
Where [<>]
means any of <
or >
and [^<>]
means any that is not of <
or >
.
And of course the mandatory link .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.