in reply to Re: regular expressions: from general to Perl to SQL
in thread regular expressions: from general to Perl to SQL

Yeah, anything more advanced is not necessary for the regular expression task at hand... portability to Perl and SQL is more important than doing nose-bleed things with Perl...

I may be forced to whip something up... or maybe japhy has something unreleased.

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

  • Comment on Re: Re: regular expressions: from general to Perl to SQL

Replies are listed 'Best First'.
Re^3: regular expressions: from general to Perl to SQL
by Aristotle (Chancellor) on Aug 14, 2003 at 21:35 UTC
    But you do have \b and \s* in your source.. those can't be emulated in SQL. In any case, since the SQL wildcards are % and _ (corresponding to .* and ., respectively), they're easy to replace to produce Perl regex syntax. So I'd store the profanity words with SQL wildcards in the definition and then
    my %rx_wild_for = ( '%' => '.*', '_' => '.' ); $profane = s/[%_]/$rx_wild_for{$1}/g;
    or something.

    Makeshifts last the longest.

Re: Re: Re: regular expressions: from general to Perl to SQL
by revdiablo (Prior) on Aug 14, 2003 at 21:28 UTC

    The simplest solution that springs to my mind is to store the SQL-compatible patterns and do a simple search-and-replace to translate them into Perl regex as needed. If there are truly only 2 different matching chars (equiv to .* and .?), this is a fairly trivial task.