Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须使用 asp.net RegularexpressionValidator 来验证来自文本框的输入。我想拒绝以开头的字符串"My Links"或者"My Urls"我已经使用了这个
"My Links"
"My Urls"
^(?!My Links|My Urls)$
但这拒绝了一切。我该怎么写这个?
If your goal is to reject all strings that start with My Links or My Urls, then you can use lookaheads, but only if you remove the $ at the end, or only the empty string will match:
My Links
My Urls
$
^(?!My Links|My Urls)
works as expected.