[Top][All Lists]

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

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

From: Andreas Schwab
Subject: Re: [^/]+ vs. [^/]* - Regular Expression bug?
Date: Wed, 10 Feb 2010 01:57:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (gnu/linux)

Morten Lauritsen Khodabocus <address@hidden> writes:

> Two regular expressions should match the same thing, but for some reason
> do not:
> [[ '/home/' =~ [^/]+ ]]; echo address@hidden
> and
> [[ '/home/' =~ [^/]* ]]; echo address@hidden
> 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 Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

reply via email to

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