[英]Regular expression - match the non digits at the end of a line
I am trying to match the characters at the end of line that contains digits and spaces. 我正在尝试匹配包含数字和空格的行尾的字符。 For example
例如
62 29N 23W 5 WATSON B 62 29N 23W 5屈臣氏B
I'd like to match "WATSON B" 我想搭配“ WATSON B”
but also match "SMITH" in the case of 但在以下情况下也要匹配“ SMITH”:
60 29N 22W 7 SMITH 60 29N 22W 7史密斯
Not completely sure what you are trying to do but you might want to try something like this: 不能完全确定您要做什么,但是您可能想要尝试如下操作:
\d{1,2} \d{1,2}[a-zA-Z] \d{1,2}[a-zA-Z] \d ([a-zA-Z\s]+)
\\d{1,2}
matches a character 1 to 2 times \\d{1,2}
匹配一个字符1至2次
\\d{1,2}[a-zA-Z]
additionally requires a character \\d{1,2}[a-zA-Z]
另外需要一个字符
([a-zA-Z\\s]+)
captures the remaining characters if they are letters or a whitespace character ([a-zA-Z\\s]+)
捕获其余字符,如果它们是字母或空格字符
This one should do it: [a-zA-Z][a-zA-Z\\s]+$
这应该做到:
[a-zA-Z][a-zA-Z\\s]+$
Made an edit. 进行了编辑。 Initial regex caught space char before name.
初始正则表达式在名称前捕获了空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.