in reply to differnce between egrep and perl regex ?

That odd-looking regex is matching "rather hot at on " followed by pretty much anything that isn't CPU, and that will work in perl as well (though /rather hot at on (?!CPU)/ would be a more natural way to do it in perl).

Perl regexs are a superset of egrep, and the extensions perl offers use syntax that is illegal as an egrep regex, according to what I see about egrep in SUSv3. (The only possible exception is that, while SUSv3 does allow the {2}, {2,}, and {1,2} quantifiers, it doesn't specify that a ? afterward has any special meaning, as it does in perl.)

  • Comment on Re: differnce between egrep and perl regex ?

Replies are listed 'Best First'.
Re^2: differnce between egrep and perl regex ?
by Random_Walk (Prior) on Oct 12, 2004 at 13:41 UTC

    Of course you are right about it being an anything but CPU match, I saw CPU in there and assumed it was looking in a very odd way for CPU rather than an egrep efficient match on (?!CPU).

    I guess my problem will be innocent litteral characters in the egrep regex that are not special there but that perl interprets as special, such as the {M,N}? where the ? is special in perl and \d, \w etc which egrep knows nothing about. I could just hope the odds are low.

    It looks like a non-trivial problem to be sure there is nothing perl regexp-ish that is not egrep regex, anyone know if there is a conversion module/tool already written, I only need do the conversion once everytime the patterns are updated (less than annual event)

    Cheers,
    R.

      You might just scan your regexes for /\\[a-z]/, but I really don't think in practice you will find anything that actually needs conversion.

      Update: Reading more closely, I see a few areas of minor concern for character classes; perl doesn't support collating symbols (e.g. [[.fu.]]) or equivalence class expressions (e.g. [[=à=]]), and perl treats backslash in a character class as an escaping character but egrep should treat it as a literal backslash.