What does the regex (\d{3})(?=\d) mean?

expression, regex, ruby

Solution

`(?=\d)` is a positive lookahead it means match & capture 3 digits that are followed by a digit.

So something like this will happen:

1234 => capture 123
123a => no match

Problem

I am new to regex, and I am trying to break down the regex so I can understand it better: ``` /(\d{3})(?=\d)/ ``` I understand that `(\d{3})` is capturing 3 digits, but unsure what the second portion is trying to capture. What does `?=` mean?

Original source

Related problems