[英]Javascript Regex to ignore first character in match
I need to ignore a '.' 我需要忽略一个'。' at the start of my regular expression, and have been somewhat stumped.
在我正则表达的开头,并且有点难过。
My current regex is: 我现在的正则表达式是:
(?::)(\d{3})
Which matches the following: 符合以下条件:
When I try to ignore the '.' 当我试图忽略'。'时 with the following regex:
使用以下正则表达式:
[^.](?::)(\d{3})
I get this: 我明白了:
As it seems to be adding the extra character like '<', which is unwanted. 因为它似乎添加了额外的字符,如'<',这是不需要的。
How do I go about to ignore that extra character in front of the ':' ? 我如何在':'前面忽略那个额外的角色?
Use this alternation based regex: 使用此基于交替的正则表达式:
\.:\d{3}|:(\d{3})
And grab captured group #1 for your matches. 并抓住你所在比赛的第一组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.