On Feb 8, 11:38 pm, Morten Lauritsen Khodabocus <mlauri...@gmail.com> wrote: > Hello, > > Ran into some particular behaviour with REs in bash, I just cannot > understand how this could possibly be correct behaviour. Then again, I > am no bash guru, could very well be me missing a clue. > > If I am wasting your time, sincere apologies. > > I am not subscribed to the list, so please include my email explicitly > in any replies that you would like me to read / respond to. > > Thanks a million for a great shell! Beers are on me next time any of you > are in Zurich. > > Here's the bashbug description: > > Configuration Information [Automatically generated, do not change]: > Machine: i486 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' > -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include > -I../bash/lib -g -O2 -Wall > uname output: Linux sony2 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 > 01:26:53 UTC 2010 i686 GNU/Linux > Machine Type: i486-pc-linux-gnu > > Bash Version: 4.0 > Patch Level: 33 > Release Status: release > > Description: > Two regular expressions should match the same thing, but for some reason > do not: > [[ '/home/' =~ [^/]+ ]]; echo ${bash_remat...@]} > and > [[ '/home/' =~ [^/]* ]]; echo ${bash_remat...@]} > the first matches 'home', the second matches nothing. The only > difference is * vs. + AFAICT, both expressions should match 'home'. > > Repeat-By: > Simply evaluate the two lines from the description. > > Thanks again, > Morten
* means zero or more characters. It found zero and stopped. You could do: [[ '/home/' =~ /([^/]*) ]]; echo ${BASH_REMATCH[1]}