On 5/21/06, Peter Volkov <[EMAIL PROTECTED]> wrote:
I have problems using =~ operator. I've tried to search for answer, but
failed. I'm using GNU bash, version 3.1.17. Can anybody give me some
examples of usage?
I really do not understand why
$ [[ "string" =~ "[a-z]" ]] && echo something
something
echo me something. IIUC the regular expression [a-z] matches any single
letter, so how string "string" matches one letter?
The =~ regexp match will match a substring by default. You can use ^ and $
to anchor the expression to the start and end of the string. You
won't get a match
with
[[ "string" =~ "^[a-z]$" ]] && echo match
But you will get a match with
[[ "string" =~ "^[a-z]{6}$" ]] && echo match
because it matches the correct number of characters.
--
Mike Stroyan
[EMAIL PROTECTED]
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash