That's because the regular expression and the previous requirements you posted do not match these desired results. Your requirements were to always have a comma after the first 1-2 digits, then have 0-3 more digits.

It appears the requirements are different:
- 1-2 digits.
- either nothing, or a comma followed by 1-3 digits.

That's two parts, the latter is divided into two sub parts: [0-9]{1,2}(,[0-9]{1,3})?
The ()? part makes everything between the () optional.

Rob Spoor wrote:That's because the regular expression and the previous requirements you posted do not match these desired results. Your requirements were to always have a comma after the first 1-2 digits, then have 0-3 more digits.

It appears the requirements are different:
- 1-2 digits.
- either nothing, or a comma followed by 1-3 digits.

That's two parts, the latter is divided into two sub parts: [0-9]{1,2}(,[0-9]{1,3})?
The ()? part makes everything between the () optional.