You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Rocky Olsen <ro...@mindphone.org> on 2005/05/12 23:12:47 UTC

Atomic Grouping but not Possessive Quantifiers?

i tried writing a couple of regexps using the possessive quantifiers '++'
and '*+' and spamassassin --lint threw up the error "invalid regexp for
rule", but was fine when i switched it to use atomic grouping.  Does SA not
support possessive quantifiers? or was it just a mistake in the lint
checking?

-Rocky


-- 
______________________________________________________________________


what's with today, today?

Email:	rocky@mindphone.org
PGP:	http://rocky.mindphone.org/rocky_mindphone.org.gpg

Re: Atomic Grouping but not Possessive Quantifiers?

Posted by Rocky Olsen <ro...@mindphone.org>.
Hehe, yeah, (?>) is atomic grouping ;)


On Thu, May 12, 2005 at 10:21:57PM -0400, Keith Ivey wrote:
> Rocky Olsen wrote:
> >no, possessive quantifiers/atomic grouping discard saved states to back
> >tracking will not occur for what was matched.
> 
> Sounds like you might be able to use (?>pattern) to do what you want. 
> See perldoc perlre.
> 
> -- 
> Keith C. Ivey <kc...@cpcug.org>
> Washington, DC

-- 
______________________________________________________________________


what's with today, today?

Email:	rocky@mindphone.org
PGP:	http://rocky.mindphone.org/rocky_mindphone.org.gpg

Re: Atomic Grouping but not Possessive Quantifiers?

Posted by Keith Ivey <kc...@cpcug.org>.
Rocky Olsen wrote:
> no, possessive quantifiers/atomic grouping discard saved states to back
> tracking will not occur for what was matched.

Sounds like you might be able to use (?>pattern) to do what you want. 
See perldoc perlre.

-- 
Keith C. Ivey <kc...@cpcug.org>
Washington, DC

Re: Atomic Grouping but not Possessive Quantifiers?

Posted by Rocky Olsen <ro...@mindphone.org>.
no, possessive quantifiers/atomic grouping discard saved states to back
tracking will not occur for what was matched.

-Rocky


On Thu, May 12, 2005 at 03:00:18PM -0700, Mike Jackson wrote:
> >AFAIK Perl doesn't support possessive Quantifiers, therefore SA does
> >not.
> 
> Is this the same as "greedy"? Aren't Perl regexes always greedy unless you 
> use +?, *?, or ??
> 

-- 
______________________________________________________________________


what's with today, today?

Email:	rocky@mindphone.org
PGP:	http://rocky.mindphone.org/rocky_mindphone.org.gpg

Re: Atomic Grouping but not Possessive Quantifiers?

Posted by Mike Jackson <mj...@barking-dog.net>.
> AFAIK Perl doesn't support possessive Quantifiers, therefore SA does
> not.

Is this the same as "greedy"? Aren't Perl regexes always greedy unless you 
use +?, *?, or ??


Re: Atomic Grouping but not Possessive Quantifiers?

Posted by Rocky Olsen <ro...@mindphone.org>.
Ah crap, you are right, perl doesn't have  possessive quantifiers. 

thx

-Rocky

On Thu, May 12, 2005 at 05:56:01PM -0400, Matt Kettler wrote:
> Rocky Olsen wrote:
> 
> >i tried writing a couple of regexps using the possessive quantifiers '++'
> >and '*+' and spamassassin --lint threw up the error "invalid regexp for
> >rule", but was fine when i switched it to use atomic grouping.  Does SA not
> >support possessive quantifiers? or was it just a mistake in the lint
> >checking?
> >
> >-Rocky
> >
> >
> >  
> >
> AFAIK Perl doesn't support possessive Quantifiers, therefore SA does
> not. The particular message you see is simply generated by SA when it
> finds perl doesn't know how to evaluate your regex.
> >From Parser.pm:
> ------------------
> sub is_regexp_valid {
>   my ($self, $name, $re) = @_;
>   if (eval { ("" =~ m{$re}); 1; }) {
>     return 1;
> 
>   } else {
>     warn "invalid regexp for rule $name: $re\n";
>     $self->{conf}->{errors}++;
>     return 0;
>   }
> }
> ----------------
> 
> Someone more educated on perl might be able to point out that it is
> supported in perl versions higher than 5.x.x, but I'm not aware of any
> import of this Java feature to perl.
> 
> Either way, your regex syntax should only be limited by what your copy
> of perl supports, not by SA.
> 
> 

-- 
______________________________________________________________________


what's with today, today?

Email:	rocky@mindphone.org
PGP:	http://rocky.mindphone.org/rocky_mindphone.org.gpg

Re: Atomic Grouping but not Possessive Quantifiers?

Posted by Matt Kettler <mk...@evi-inc.com>.
Rocky Olsen wrote:

>i tried writing a couple of regexps using the possessive quantifiers '++'
>and '*+' and spamassassin --lint threw up the error "invalid regexp for
>rule", but was fine when i switched it to use atomic grouping.  Does SA not
>support possessive quantifiers? or was it just a mistake in the lint
>checking?
>
>-Rocky
>
>
>  
>
AFAIK Perl doesn't support possessive Quantifiers, therefore SA does
not. The particular message you see is simply generated by SA when it
finds perl doesn't know how to evaluate your regex.
>From Parser.pm:
------------------
sub is_regexp_valid {
  my ($self, $name, $re) = @_;
  if (eval { ("" =~ m{$re}); 1; }) {
    return 1;

  } else {
    warn "invalid regexp for rule $name: $re\n";
    $self->{conf}->{errors}++;
    return 0;
  }
}
----------------

Someone more educated on perl might be able to point out that it is
supported in perl versions higher than 5.x.x, but I'm not aware of any
import of this Java feature to perl.

Either way, your regex syntax should only be limited by what your copy
of perl supports, not by SA.