http://www.perlmonks.org?node_id=1055837


in reply to Re: regular expression inverse match NOT match?
in thread regular expression inverse match NOT match?

If it's just spaces, then you can use

/AB\s*CDE/

But if they can be any characters except the sequence CDE, you can use

/AB(?:(?!CDE).)*CDE/s

(?:(?!PAT).)* is to PAT as [^CHAR]* is to CHAR.