in reply to Regex libraries

My Problem is, if it is reasonable to convice my boss to implement a full Perl compatible Regex library?

Maybe, maybe not. But how should we know? It would entirely depend on what kind of regexes you need. It's kind of hard to convince your boss to assign resources to adding PCRE to your product because "it has lookahead" when you yourself haven't found a lot of uses for it.

The last thing you should do to have Perl been accepted on the workfloor is to act like a zealot. If Perl is needed, it will come. But if it can be done with Boost, and Boost is faster, then I wouldn't push for anything else - unless I have arguments of my own.

Replies are listed 'Best First'.
Re^2: Regex libraries
by Schuk (Pilgrim) on Dec 29, 2004 at 17:25 UTC
    You´re right.
    If I dont have an important feature which I would miss in the future its quite useless to whine about something I dont have and actually dont know how to apply correctly.
    Perhaps I expressed myself unclear (sorry for that) I do have one or two cases where Lookaheads are usefull but I am still thinking I could also write them in Boost. Unfortunatly I havent found out how yet:

    Perl goes: /(?=.*\.)/

    Boost goes: /[^.]*/

    Actually I just got aware that the second regex without Lookahead is much more usefull because its more flexible. I simply didnt thought well enough about my problem.

    I should take myself more time to think about problems. One week still isnt enough ;-) I probably should wipe my ideas if I havent solved them in one day.
    The obvious often hides behind the complicated.

    Anyhow. I just made the decision to use the library which is currently implemented. I was more frightend to have something I wouldnt be able to work with. And I needed to see this written down somewhere *g

    Thanks for pointing me in the right direction

      /(?=.*\.)/ and /[^.]*/ are not the same thing at all.

      'booga' =~ /[^.]*/ matches. 'booga.' =~ /[^.]*/ matches. 'booga' =~ /(?=.*\.)/ does not match. 'booga.' =~ /(?=.*\.)/ matches. '4.6.8' =~ /[^.]*\.(\d)/ returns 6 in $1. '4.6.8' =~ /(?=.*\.)(\d)/ returns 4 in $1. '4.6.8' =~ /((?=.*\.))\1(\d)/ returns 8 in $2. .* matched a "4.6" '4.6.8' =~ /.*\.(\d)/ returns 8 in $1. Lookahead not needed. '4.6.8' =~ /(?:(?!\.).)*(\d)/ returns 6 in $1. You want neg lookahead

      /(?=.*\.)/ requires a "." in the string. /[^.]*/ does not requires a "." in the string. /[^.]*/ is equivalent of the negative lookahead /(?:(?!\.).)*/. The advantage of the negative lookahead version is that you can negatively match more than one character: /(?:(?!$re).)*/. If I only wanted to negatively match one character, I'd use [^...], even in Perl.

      Side thought: Hum, It would be nice if /(?:(?!$re).)*/ could be shortcutted to /(?^$re)/, since that's the typical use of a negative lookahead.