How to use [[ string =~ regexp ]]?

2006-05-21 Thread Peter Volkov
Hello. Please CC my email to answers as I'm not subscribed to the list. 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

locally declared arrays do not act as arrays

2006-05-21 Thread Andrew Stitt
Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale'

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Paul Jarc
Peter Volkov [EMAIL PROTECTED] wrote: $ [[ string =~ [a-z] ]] echo something something [a-z] matches only one charater, but the pattern is not required to match against the entire string. You can force it to match the whole string by using ^ to anchor the pattern to the beginning of the

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Mike Stroyan
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

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Chet Ramey
Peter Volkov wrote: Hello. Please CC my email to answers as I'm not subscribed to the list. 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

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Chet Ramey
Paul Jarc wrote: Peter Volkov [EMAIL PROTECTED] wrote: $ [[ string =~ [a-z] ]] echo something something [a-z] matches only one charater, but the pattern is not required to match against the entire string. You can force it to match the whole string by using ^ to anchor the pattern to the

Re: locally declared arrays do not act as arrays

2006-05-21 Thread Chet Ramey
Andrew Stitt wrote: Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc'

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Bob Proulx
Chet Ramey wrote: Peter Volkov wrote: Please CC my email to answers as I'm not subscribed to the list. $ [[ string =~ [a-z] ]] echo something something ... The real question is whether or not quoting the pattern should work as it does with other [[ pattern matching operators, which is

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Chet Ramey
Bob Proulx wrote: Chet Ramey wrote: Peter Volkov wrote: Please CC my email to answers as I'm not subscribed to the list. $ [[ string =~ [a-z] ]] echo something something ... The real question is whether or not quoting the pattern should work as it does with other [[ pattern matching

Re: How to use [[ string =~ regexp ]]?

2006-05-21 Thread Bob Proulx
Chet Ramey wrote: It seems reasonable that quoting any part of the rhs to the =~ operator should cause it to behave in the same manner. Since the arguments to [[ don't undergo any of the expansions that require quoting to protect them, there's no reason for =~ to act differently than the