Item1975: Adding match operator =~ in queries

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Enhancement Closed Engine    
... for %IF and %SEARCH ...

The code below implements a
=~
operator following the notation from DBCacheContrib. This one is different from
~
which is more of a glob match.

When these operators a translated to SQL, the match operator will most probably be limited to POSIX 1003.2 Extended Regular Expressions as DBs don't have the full power of perl regexes at hand.

Not sure if there is a way to force a regex to be interpreted POSIXish in perl as that does not make much sense normally.

package Foswiki::Query::OP_match;

use strict;

use Foswiki::Query::BinaryOP ();
our @ISA = ('Foswiki::Query::BinaryOP');

sub new {
    my $class = shift;
    return $class->SUPER::new( name => '=~', prec => 500 );
}

sub evaluate {
    my $this = shift;
    my $node = shift;
    return $this->evalTest(
        $node,
        \@_,
        sub {
            defined( $_[0] ) && defined( $_[1] )
              && $_[0] =~ m/$_[1]/s ? 1 : 0;
        }
    );
}

1;

Michael and I have been discussing this offline, and are agreed that support for POSIX regexes is an excellent enhancement. Confirmed.

Regarding POSIX compliance, see http://search.cpan.org/~jettero/POSIX-Regex-1.0001/Regex.pod

-- CrawfordCurrie - 26 Aug 2009

What was the feature proposal topic for this old one?

I do not remember seeing a feature proposal for this, but I could just be short of memory.

I scanned through the accepted feature proposals and I cannot see one that match from the headlines.

-- KennethLavrsen - 25 Mar 2010

how the *? can you claim to be waiting for release when you have broken the unit tests for Fn_IF ?

-- SvenDowideit - 26 Mar 2010

Can't find feature proposal either. Creating one: AddMatchOperatorToQueryLanguage

I am fine reverting the code immediately. However, it makes sense to have the code in the core discussing the related bug in the Infix::Parser.

-- MichaelDaum - 26 Mar 2010

Rationalised support for escaped chars in constant strings; moved unit tests to QueryTests.

-- CrawfordCurrie - 26 Mar 2010

ItemTemplate edit

Summary Adding match operator =~ in queries
ReportedBy MichaelDaum
Codebase trunk
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component
Priority Enhancement
CurrentState Closed
WaitingFor
Checkins Foswikirev:6903 Foswikirev:6904 Foswikirev:6905 Foswikirev:6917 Foswikirev:6918 Foswikirev:6926 Foswikirev:6929 Foswikirev:6930 Foswikirev:6931
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r21 - 04 Oct 2010, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License