farzanj
asked on
Bash Regular expression
The result of the following match is successful. Why?
x=12345 ; [[ $x =~ ^[0-9]{3} ]] && echo 3 digits
I thought I wanted only 3 digits. So to me it should have failed. I was only expecting it to work for x=123.
Please explain. Also if I want to match only 3 digits, what would be the regular expression?
x=12345 ; [[ $x =~ ^[0-9]{3} ]] && echo 3 digits
I thought I wanted only 3 digits. So to me it should have failed. I was only expecting it to work for x=123.
Please explain. Also if I want to match only 3 digits, what would be the regular expression?
Are you saying it echoed "12345"? It echoed 5 digits?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help. Appreciated
ASKER
I think due change of interface, I had awarded points but it did not go through. Please open it again so that I can award points. Thanks.