[英]How can I write a regular expression (regex) to exclude the words US and USA?
I have a form on my website that a form field for COUNTY.我的网站上有一个表格,其中包含 COUNTY 的表格字段。 People routinely misread this as COUNTRY and end up putting into the field US or USA.
人们经常将其误读为“国家/地区”,并最终将其投入“美国”或“美国”领域。
Is there regex that I can use to exclude the words:有没有我可以用来排除这些词的正则表达式:
US USA us usa美国 美国 我们美国
Thank you.谢谢你。
I searched the internet to see if this has been asked before and it has not been from what I can tell.我在互联网上搜索,看看以前是否有人问过这个问题,但据我所知还没有。 I don't know how to write regex or expressions either though.
我也不知道如何编写正则表达式或表达式。
Use a negative lookahead to exclude a word.使用否定前瞻来排除一个词。
Match US
optionally followed by A
.匹配
US
后跟A
。
<form> County: <input type="text" pattern="(??[Uu][Ss][Aa].$).*"> </form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.