Reputation: 564
I have this text:
arnaldo felix toro calzadilla tomo 133 l 002353 p 119 numero 119
and using this regex: t[^\s]{0,4} (\d*)\s*
to find the string tomo 133
, that matches the whole pattern.
Instead I'm getting 2 matches:
toro
andtomo 133
I want to match only the second one.
As you can see is not multiline, anchor or case-sensitive problem. Anchors don't solve the problem 'cause i'm not dealing with whole lines inputs.
I'm using PHP7, using preg_match_all()
, but preg_match()
don't make a difference.
Save the expression here in case you want to play with it https://regex101.com/r/aRxqvI/1.
Thanks for your time
Upvotes: 2
Views: 77
Reputation: 78994
\d*
matches a digit character 0
or more times (so optional) because of the *
. You want +
for 1
or more times: \d+
Upvotes: 1