Morten Lauritsen Khodabocus <mlauritse@gmail.com> writes:
> Two regular expressions should match the same thing, but for some reason
> do not:
> [[ '/home/' =~ [^/]+ ]]; echo ${BASH_REMATCH[@]}
> and
> [[ '/home/' =~ [^/]* ]]; echo ${BASH_REMATCH[@]}
> the first matches 'home', the second matches nothing. The only difference
> is * vs. + AFAICT, both expressions should match 'home'.
"[^/]*" matches the null string at the start of '/home/', and there is
no reason for the matcher to try another match.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."