|
|
| The stupid question is the question not asked | |
| PerlMonks |
Problem with negative lookahead at end of stringby olivierp (Hermit) |
| on Jun 21, 2004 at 11:00 UTC ( [id://368464]=perlquestion: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.olivierp has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks !
I'm having trouble building a regex that would match as follows: string starts with chars, contains this, but does not contain that and does not end with whatever A couple of samples:
^chars(?!.*that).*this(?!.*that).* If I include the whatever part, as here ^chars(?!.*that).*this(?!.*that).*(?!.*whatever)$ , sample 2 still matches, whereas this: ^chars(?!.*that).*this(?!.*that).*[^w][^h][^a][^t][^e][^v][^e][^r]$ excludes sample 2 but is horrible... Am I missing something with the negative lookahead, or is it not possible to do such a thing ? -- Olivier Edited by demerphq: Changed </br> to <br />
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||