What the regex was doing was "match one digit", and it would match each digit by separate, so 1234 would match as '1', '2', '3', '4' instead of '1234'. You can check this by adding a ^ and a $ to the start and end of the regex respectively.
Examples from regexr.com:
By adding the + at the end of the regex, what the regex does now is "match one or more of the preceding pattern".
Here is an example of what I mean
What the regex was doing was "match one digit", and it would match each digit by separate, so 1234 would match as
'1', '2', '3', '4'
instead of'1234'
. You can check this by adding a^
and a$
to the start and end of the regex respectively. Examples from regexr.com:By adding the
+
at the end of the regex, what the regex does now is "match one or more of the preceding pattern".