Javascript regex ignore first character in match

I need to ignore '.' at the beginning of my regular expression, and there were a few dead ends.

My current regex is:

(?::)(\d{3})

Which corresponds to the following:

Image here

When I try to ignore '.' with the following regular expression:

[^.](?::)(\d{3})

I get this:

Picture here

It seems that adding an extra character, such as '<', is undesirable.

How can I ignore this extra character before the ':'?

+4
source share
2 answers

Use this interleave regular expression:

\.:\d{3}|:(\d{3})

And grab the captured group # 1 for your matches.

RegEx Demo

+2
source

lookahead :\d{3}, , .

(?=[^.](:(\d{3})))

DEMO

1 :, 2 .

+1

All Articles