H
harsha.ramanagoudra
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
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