Reputation: 589
[\d-.]+
works but [\d-.]*
does not. The only thing I changed is the +
to *
at the end.
<b>12345</b>
<b>12345-6789</b>
<i>1234.5678</i>
<tag>1234-2342346456</tag>
I tested it out here http://regexr.com?30ngn
The *
means 0 or more while +
means 1 or more. Does the *
only work with .
?
Upvotes: 2
Views: 106
Reputation: 4882
The *
operator works fine, it's just regexr acting funny, or it is due to your hazardous use of the -
character in a regex character class. If you want to match a -
character in a character class, put it at the beginning; otherwise, the regex engine may think you want to match a range (such as [A-Z]
).
The fixed regex [-\d.]*
works just fine at regexpal.
Upvotes: 3