in reply to Valid date in regex only

mAsterdam wrote:

They had to validate a date in a string with only a regular expression (and one only), due to environmental/tool contraints.

With all due respect, it's difficult to know how to answer this. What is their tool? Perl regular expressions tend to be much more expressive than most other language's regexen, so a direct conversion from a Perl regex to another language's regex may not be possible. If you just want comments on the Perl aspect, well, what you are doing is impressive, but it's the wrong tool for the job. If you want to know how you can use this for the other language, we can't answer that. Heck, for all I know, the other tool could use a DFA engine instead of an NFA engine, thus making a direct comparison very problematic.

Incidentally, judging from your email address and your username, I couldn't help but wonder if you have any association with the Hippies from Hell. If so, tell Willem Hengveld that "Curtis" says "hi" :) (I used to work with him)

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: (Ovid) Re: Valid date in regex only
by mAsterdam (Sexton) on Mar 23, 2002 at 03:36 UTC
    Ovid wrote:

    <quote>    What is their tool?</quote>

    The tool is called "teamsite". According to my collegues the manual states nothing much about the exact regex-implementation but that it uses "perl-like regular expressions" (no perl-version).

    And:

    <quote>    ...direct conversion from a Perl regex to another language's regex may not be possible</quote>

    changing the outer delimiters and removing comments, spaces, '?:' and the x-modifier did the job for teamsite, leaving (as said) an unreadable string of hooks, parens, hyphens and digits. something like (I don't have the final string here):

    validation-regex="^(((0?[1-9]|1\d|2[0-8])/(0?[1-9]|1[0-2])(29|30)/(0?[ +13-9]|1[0-2])31/(0?[13578]|1[02]))/\d{4}|29/0?2/(\d\d(0[48]|[2468][04 +8]|[13579][26])|([02468][048]|[13579][26])00))$"

    But it worked :-)

    Thanks for the prompt response.
    I don't know Willem (or the Hippies you mentioned) but if I ever meet him I'll say hi from Curtis.

    Regards,

    Danny