Re: Extract alternate patterns
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Mon, 17 Jul 2006 16:10:21 +0200
harsha.ramanagoudra@xxxxxxxxx wrote:
I am trying to extract alternate patterns in strings. The difficulty
is because of optional patterns.
Below is the code,$transaction is the search string.
if($transaction =~ /(addReq|modReq|subtractReq)+?.*?(addReq)?/){
print "$1..$2\n";
}
The above code is succeeding to match the first pattern but always
fails to match the optional second addReq. The output I get is
addReq..
One idea:
/(addReq|modReq|subtractReq)(?:.*(?=addReq)|.*)(addReq)?/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- Extract alternate patterns
- From: harsha . ramanagoudra
- Extract alternate patterns
- Prev by Date: Re: Perl equivalent of this script?
- Next by Date: Re: Extract alternate patterns
- Previous by thread: Extract alternate patterns
- Next by thread: Re: Extract alternate patterns
- Index(es):