in reply to can I make my regex match first pattern instead of last?
Ah, yes. Drop the useless initial subpattern (.+) (you only reproduce what it captures anyway) and you'll be much closer to home. Capturing the rest of the string after what you care for, is unnecessary too, for the same reason.$DataToParse =~ s/(.+)\sELEMENT\s(.+?)\s\(Item := \"$item\".+? +CatalogNumber := \"$catNum.+?END_ELEMENT/$1 ***** Found $2\'s $catNum + $item. (counter: $counter) *****$3/s;
A regex doesn't have to match a whole string, you know.
$DataToParse =~ s/\sELEMENT\s(.+?)\s\(Item := \"$item\".+?Cata +logNumber := \"$catNum.+?END_ELEMENT/ ***** Found $1\'s $catNum $item +. (counter: $counter) *****/s;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: can I make my regex match first pattern instead of last?
by kleucht (Beadle) on Oct 25, 2008 at 20:53 UTC |