Need basic parsing/regex help

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Need basic parsing/regex help

 
0
  #1
Mar 13th, 2007
I'm new to perl (and actually not even really trying to develop this skill - I inherited some code and am trying to enhance it).

Basically, I want to get the text between parts of a text string.
How do I get the parsed variable to contain "WHATEVER IT IS"?
  1. #!/usr/bin/perl
  2. $var="BLAH{108:WHATEVER IT IS}HEY";
  3. $parsed=($var =~ /\{108:(\w*)\}/);
  4. print "PARSED:$parsed\n";
Last edited by winbatch; Mar 13th, 2007 at 9:23 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 898
Reputation: KevinADC has a spectacular aura about KevinADC has a spectacular aura about 
Solved Threads: 67
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Posting Shark

Re: Need basic parsing/regex help

 
0
  #2
Mar 13th, 2007
  1. ($parsed) = $var =~ /\{108:([^}]*)\}/;
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Need basic parsing/regex help

 
0
  #3
Mar 13th, 2007
Originally Posted by KevinADC View Post
  1. ($parsed) = $var =~ /\{108:([^}]*)\}/;
Worked like a charm. Thanks! (Maybe some day I'll understand it)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC