bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [^/]+ vs. [^/]* - Regular Expression bug?


From: Morten Lauritsen Khodabocus
Subject: Re: [^/]+ vs. [^/]* - Regular Expression bug?
Date: Thu, 11 Feb 2010 10:24:20 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Hi again,

Oh, right, that makes sense. And like I feared, I was indeed wasting your time.

Thanks for the info, sorry about the time.

Morten

Andreas Schwab wrote:
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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]