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.
我正在尝试为街道地址编写正则表达式。示例:124 Street 我不太确定该怎么做。到目前为止,我有一些看起来像这样的东西 ^[0-9][a-zA-Z]$。 但是,这是行不通的。任何帮助将不胜感激。 谢谢!
124 Street
^[0-9][a-zA-Z]$
^[0-9][a-zA-Z]$将匹配一个数字后跟一个字母。
如果要匹配任何仅由字母、数字、空格和句点组成的非空字符串,请使用
^[0-9a-zA-Z. ]+$
如果要匹配(一串数字和一个空格)可选,后跟一串字母和空格,那就是
^([0-9]+ )?[a-zA-Z ]+$
也许这是一个更好的
`'^((Flat [1-9][0-9]*, )?([1-9][0-9]* ))?([A-Z][a-z]* )*([A-Z][a-z]*)$'`