Re: Proposal for \v and \V, the small- and large- cut regex opera tors.

2000-08-10 Thread Bart Lateur

On Thu, 10 Aug 2000 04:42:56 -0400, Ilya Zakharevich wrote:

 Variable interpolation can be handled using Damian's curried expressions.

On XRay:

Summary for query "curried;Damian":

   found 0 matches in 0 files.

Look up RFC 23 on http://dev.perl.org/rfc/: "Higher order functions".

-- 
Bart.



Re: Proposal for \v and \V, the small- and large- cut regex opera tors.

2000-08-10 Thread Ilya Zakharevich

On Thu, Aug 10, 2000 at 11:12:28AM +0200, Johan Vromans wrote:
 Of course, we need group names (trivial), and group temporaries.
 I needed the latter to define a generic pattern to match quoted strings:
 you need to store the starting quote somewhere to find the ending quote,
 but I didn't want this to have impact on the pattern as a whole. E.g.,
 
$qp = qr/((['"]).*?\2)/;
@a = $str =~ /$qp/g;
 
 and have @a contain only the quoted strings, and not (also) the individual
 quotes.

 $quoted = qr/(['"]).*?\2/;
 @a = $str =~ /($quoted)/gp;

Here //p is the "postponed" flag.  Put (?p{$quoted}) instead of
$quoted to get this semantic now (or some other char).

Ilya



Re: Proposal for \v and \V, the small- and large- cut regex opera tors.

2000-08-10 Thread Johan Vromans

On Thu, Aug 10, 2000 at 07:04:50AM -0400, Ilya Zakharevich wrote:
  $quoted = qr/(['"]).*?\2/;
  @a = $str =~ /($quoted)/gp;
 
 Here //p is the "postponed" flag.  Put (?p{$quoted}) instead of
 $quoted to get this semantic now (or some other char).

 $quoted = qr/(['"]).*?\1/;
 @a = $str =~ /(??{$quoted})/g;

does the trick, thanks!

-- Johan



Re: Proposal for \v and \V, the small- and large- cut regex opera tors.

2000-08-10 Thread Johan Vromans

On Thu, Aug 10, 2000 at 04:42:56AM -0400, Ilya Zakharevich wrote:
 These are just user-defined ops.  You should be able to overwrite the
 normal ops, as in:
 
   sub match_all {
 use re_ops 'overload_usual_ops';
 "(" . group(1, [ 'a' .. 'z' ] * [3,5] ) . ")"
   }
 
 Will this go?

I think so.
Of course, we need group names (trivial), and group temporaries.
I needed the latter to define a generic pattern to match quoted strings:
you need to store the starting quote somewhere to find the ending quote,
but I didn't want this to have impact on the pattern as a whole. E.g.,

   $qp = qr/((['"]).*?\2)/;
   @a = $str =~ /$qp/g;

and have @a contain only the quoted strings, and not (also) the individual
quotes.

  Variable interpolation can be handled using Damian's curried expressions.
 On XRay:
 Summary for query "curried;Damian":
found 0 matches in 0 files.

http://tmtowtdi.perl.org/rfc/23.pod

-- Johan



Re: Proposal for \v and \V, the small- and large- cut regex opera tors.

2000-08-10 Thread Johan Vromans

On Wed, Aug 09, 2000 at 04:20:32PM -0400, Ilya Zakharevich wrote:
 It is not clear though how to design concise-but-no-line-noise
 notation for \w etc.  But qr/ \( ( [a-z]{3,5} ) \) / may become
 
   "(" (.) group(1, [[ 'a' .. 'z' ]] (*) [3,5] ) (.) ")"
 
 here (.) is the ASCII substitution for the UNICODE "REx concatenate"
 char, similarly for [[. ]] and (*).  (The chars may be borrowed from
 the math repertoire.)

Hmm. Looks nice. How about pattern functions, e.g.,

  sub match_all : pattern {
"(" . group(1, [ 'a' .. 'z' ] * [3,5] ) . ")"
  }

Variable interpolation can be handled using Damian's curried expressions.

-- Johan