Hmm, probably you should. To use two of them in AND combination, just... use
two of them. )

/^(?![[:upper:]][[:upper:]])(?!\d)/

And it gets even better: you may mix any number of look-aheads in a single
regex this way. )

-- iD

2011/10/13 Hamann, T.D. (Thomas) <[email protected]>

>
> Hi,
>
> I am trying to write a regex that should only match when certain patterns
> are not present, e.g. when a line does not start with either a digit or
> ALL-CAPS text. I figured I could use negative look-aheads for this.
>
> I can write it as:
>
> if (/^(?![[:upper:]][[:upper:]])/) {
>    if (/^(?!\d)/) {
>    s/^/<test>/;
>    }
>    else {
>    }
> }
> else {
> }
>
> However, I was wondering whether there was a way of writing this as a
> single if loop, because there are much more than two situations that should
> not be matched.
>
> I tried to write it as:
>
> if (/^(?![[:upper:]][[:upper:]])|^(?!\d)/) {
> s/^/<test>/;
> }
> else {
> }
>
> but this means if one option is not matched the other one is matched, which
> is not what I want. So I need something that does the equivalent of "Don't
> match this AND don't match this". Is this possible in a if loop, or should I
> use something else?
>
> Thanks,
>
> Regards,
> Thomas Hamann
>
> --
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
>

Reply via email to