我有这个字符串:
3 V1388832414 N1 G96ca813824e9c752da0d0000ffe8688c
我的注册表是:
\d.\s.V13\d+\s.N\d.\s.\w*
但它不匹配。 我试着说:一个数字第一个和一个白色空间和字符V13和任何一个数字有一个或多个长度和一个白色空间和字符N和一个数字和一个白色空格和任何长度的任何字符。
答案 0 :(得分:1)
为什么你有这么多不必要的.
。这应该足够了:
\d\sV13\d+\sN\d\s\w*
我不完全确定为什么你的正则表达式中有.
。 .
用于匹配任何单个字符,因此您的正则表达式无法正常工作
答案 1 :(得分:1)
请改为尝试:
\d\s*V13\d+\s*N\d\s*\w*
\d match a digit [0-9]
\s* match any white space character [\r\n\t\f ]
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
V13 matches the characters V13 literally (case sensitive)
\d+ match a digit [0-9]
Quantifier: Between one and unlimited times, as many times as possible, giving back as needed [greedy]
\s* match any white space character [\r\n\t\f ]
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
N matches the character N literally (case sensitive)
\d match a digit [0-9]
\s* match any white space character [\r\n\t\f ]
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
\w* match any word character [a-zA-Z0-9_]
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]