Extract alternate patterns
- From: harsha.ramanagoudra@xxxxxxxxx
- Date: 17 Jul 2006 06:31:41 -0700
Hi all,
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..
My intention is that this search extracts patterns like those below. In
some cases $2 may be undef
addReq
addReq..addReq
modReq..addReq
subtractReq
Thanks
Harsha
.
- Follow-Ups:
- Re: Extract alternate patterns
- From: Ben Bacarisse
- Re: Extract alternate patterns
- From: Gunnar Hjalmarsson
- Re: Extract alternate patterns
- Prev by Date: Re: How to local-ly close a handle?
- Next by Date: A subroutine for gcd
- Previous by thread: FAQ 2.13 What mailing lists are there for Perl?
- Next by thread: Re: Extract alternate patterns
- Index(es):
Relevant Pages
|