I tried find a regular expression that matches any number between 1 and 999. When is uses hooks I get a syntax error
(bash: syntax error near unexpected token `(')
and when I don't use the hooks nothing happens.
my regex is:
egrep ^([1-9][0-9]?|)$ Numbers
update:
but how can i get him to check the file i want him to check, because know i can check the numbers if i use echo but i should check the file
This should match any number between 1 and 999. I added the
{0,2}
which means match between 0 and 2 repeats of the [0-9] character group.If you are trying to match the parenthesis and pipe character, then you'll need to escape them:
Enclose the regex in double-quotes or escape the parantheses and pipes with backslash.
e.g.
egrep "^([1-9][0-9]?|)$"
oregrep ^\([1-9][0-9]?\|\)$
.BTW, your regex seems to be broken. How about
egrep "^[1-9][0-9]?[0-9]?$"
?Try this one: