Luke Palmer writes:
> Hans Ginzel writes:
> >     Hello,
> > 
> >    I am missing, in Perl5, some shortcut for matching not whole word,
> > e.g.:
> > 
> >     /^--v(?:e(?:r(?:s(?:i(?:on?)?)?)?)?)?$/
> > 
> > Would there be something in Perl6?
> 
> Well, I don't think there's an *exact* substitute for that maximally
> efficient pattern (but I'm no regex guru), but this ought to work:
> 
>     /^ --(v\w*): <( 'version'.substr(0, $1.chars) eq $1 )> $/
> 
> And you could always write a rule:
> 
>     rule partial ($str) {
>         $str.substr(0,1) <partial $str.substr(1)>?
>     }

Except that that particular rule results in an infinite loop :-)

    rule partial ($str) {
        <if $str, <fail>> <null>
      | $str.substr(0,1) <partial $str.substr(1)>?
    }

Luke

Reply via email to