Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come this RegEx isn't working quite right?

Tags:

regex

I have this RegEx here:

/^function(\d)$/

It matches function(5) but not function(55). How come?

like image 701
Charlie Brown Avatar asked Jan 19 '26 01:01

Charlie Brown


1 Answers

The other posters are correct about the +, but what language are you using for to parse the regular expression? Shouldn't you have to escape the ()? Otherwise it should capture the digit(s).

I would think you would need...

/^function\(\d+\)$/
like image 129
Mike Schall Avatar answered Jan 21 '26 21:01

Mike Schall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!