in reply to Re: Re: Regex (lookahead) Confusion
in thread Regex (lookahead) Confusion

So let's see if I understand this and please correct me if I'm wrong.

The ?: means that the parens are just for grouping and will load any matches into $1, $2, etc.
Then the character class in parens
and then the lookahead...
?! means that it is a negative lookahead
.* means any character 0 or more times (very greedy)
\1 is related to the character matched from the character class
It's the .* that is throwing me off. To me, that looks like it would match a single character repeated any number of times but not separated duplicate characters. I just don't understand it ... yet. I will keep looking.
  • Comment on Re: Re: Re: Regex (lookahead) Confusion

Replies are listed 'Best First'.
Re: Re: Re: Re: Regex (lookahead) Confusion
by allolex (Curate) on Feb 05, 2004 at 22:10 UTC

    s/will load/will not load/, right?

    The .* is saying there can be any number of characters in the string between the first match (the character class) and the backreference (\1) match, from zero (two characters next to each other) on up...

    Say out first match was 'a', then 'a' is also referred to in \1. Then we have a.*a: aa,  a.a,  a..a,  a...a,  a....a, etc. And its a negative lookahead, so if any one of those combinations matches, the regex will fail.

    --
    Allolex