in reply to [perlre] grouping parenthesis capture whole string instead of proper subset... why?

Pipes are special in regexpen, therefore you need to escape them, for example using the \Q trick:
use strict; my $string="altcategory=||"; $string =~ /(.*)\Q||\E$/; print $1;
or by introducing leaning toothpick (or cross-eyed plumbing in the case of pipes) syndrome:
$string=~/(.*)\|\|$/;

CU
Robartes-

  • Comment on Re: [perlre] grouping parenthesis capture whole string instead of proper subset... why?
  • Select or Download Code