Actually, using {3,3} doesn't help at all for ensuring that there may only be 3 consecutive digits. All it ensures is that the regex engine will only match the first 3 consecutive digits, but it will not result in a failing match when there are more digits.

Observe:

//echo -a $regex(1234,/(\d{3,3})/) -> $regml(1)

echoes 1 -> 123, even though it is clear that you only wanted the regex to match in case there are only 3 consecutive digits, no more, no less. The thing is that the engine did only match 3 digits, which is shown by the regml, but it didn't make the regex match fail even with that extra 4th one.

If you want to enforce this regex to only match in case of 3 and no more, you need to use some kind of boundary check like for instance:

\d{3}(?!\d) -> makes sure that whatever comes after the 3 digits isn't a digit, but can be every other char or the end of the string.

\d{3}(?= |$) -> enforces that any sequence of 3 digits is followed by either a space or the end of the string.

...

Typing this post was a drag with one hand, as I had an accident yesterday and broke my shoulder. I need speech technology frown


Gone.