I have this RegEx here:
/^function(\d)$/
It matches function(5)
but not function(55)
. How come?
I have this RegEx here:
/^function(\d)$/
It matches function(5)
but not function(55)
. How come?
Because you only gave it one \d
. If you want to match more than one digit, tell it so.
/^function(\d+)$/
You need to add the +
to make the \d (digits) greedy -- to match as much as possible. (Assuming that is what you are after as it would probably match
function(3242345235234235235234234234535325234235235234523)
as well as function(55)
Repeats the previous item once or more. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only once.
referring to +
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+\)$/