[Pdx-pm] regexp and semi-greedy match

Joshua Keroes joshua at keroes.com
Mon Oct 15 08:24:30 PDT 2007


Non-greedy preliminary match for basename then greedy \d match for int.

DB<1> $_ = 'foo-121.raw-456.raw';
DB<2> ($base, $int) = /^(.*?)-(\d+).raw$/
DB<3> printf " base=%s\n int=%s\n fill=%06d", $base, $int, $int;
 base=foo-121.raw
 int=456
 fill=000456


More information about the Pdx-pm-list mailing list