I encountered a parse problem and I'm hoping one of your experts can help me with.
I have a text string which I want to parse into 2 separate variables. The string is made up of 2 portions, <portion1><portion2>, where portion1 can be any texts but portion2 is one of the following Crit, Maj, or Okay.
#Sample strings in an array: my @a = ('SystemMaj', 'MemoryCrit','ServerOkay', 'MemoryOkay');
How would you write the code to accomplish this? I tried the following but failed.
#code sample my @a = ('SystemMaj', 'MemoryCrit','ServerOkay', 'MemoryOkay'); foreach my $v (@a) { $v =~ m/(\w+[^(?:Crit|?:Maj|?:Okay])(\w+)/; print "1: $1 2:$2\n"; }
#sample output 1: System 2:Maj #correct 1: Memo 2:ryCrit #should be 1: Memory 2: Crit 1: Serve 2:rOkay #should be 1: Server 2: Okay 1: Memo 2:ryOkay #should be 1: Memory 2: Okay
Thanks for your help.
fujimanIn reply to Parse String Question by fujiman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |