|Do you know where your variables are?|
Writing a negative regex using =~by ftumsh (Scribe)
|on Oct 17, 2012 at 09:36 UTC||Need Help??|
ftumsh has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to implement a -ve regex using only the =~ construct. ie The regex should match if a string is not found in the source string. I am using a daemon that accepts regexes and applies them to files, which is why I am stuck with the =~ construct.Here is a sample string:
I should like to have a positive match if the string doesn't contain GBFER and GBFOO. Just like !~ /(?:GBFER|GBFOO)/.
All I can know about the string is that it starts with "L," and has a fixed number of commas. Everything between the commas may be zero or multiple alphanumeric. Also, the bit I am wanting to test will be between the 11th and 12th commas.
I did have the (as I thought hours ago) wizzo idea of having a conditional regex with a look ahead assertion. If the lookahead matched, I'd use a regex that always failed. If the look ahead didn't match, I'd use a regex that always matched.
However, after hours of google and RTFM, I can't get it to work (it is another node)...
So, any and all comments, ideas, pointers, welcomed.Warmly John