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
Thread Next