[geeks] bash string matching
der Mouse
mouse at Rodents.Montreal.QC.CA
Wed Jun 4 21:01:48 CDT 2008
> [[ "$STRING" =~ "*is a geek*" ]] && echo geek
> [[ "$STRING" =~ ".*is a geek.*" ]] && echo geek
> However, as soon as you need to quote to enclose spaces or other
> delimiters, the matching breaks.
I'm not surprised. Quoted globbing characters are no longer globbing
characters in every context I've seen.
Try [[ "$STRING" =~ *"is a geek"* ]] instead.
It's like the difference between `echo "*.c"' and `echo *".c"'.
Or, of course, bash could be doing something totally funky here; I do
not actually know bash - I'm just guessing that it'll work the way most
quoting does.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse at rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
More information about the geeks
mailing list