944,008 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 2437
  • Perl RSS
Mar 13th, 2007
0

Need basic parsing/regex help

Expand Post »
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"?
Perl Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
Mar 13th, 2007
0

Re: Need basic parsing/regex help

Perl Syntax (Toggle Plain Text)
  1. ($parsed) = $var =~ /\{108:([^}]*)\}/;
Reputation Points: 246
Solved Threads: 67
Practically a Posting Shark
KevinADC is offline Offline
898 posts
since Mar 2006
Mar 13th, 2007
0

Re: Need basic parsing/regex help

Click to Expand / Collapse  Quote originally posted by KevinADC ...
Perl Syntax (Toggle Plain Text)
  1. ($parsed) = $var =~ /\{108:([^}]*)\}/;
Worked like a charm. Thanks! (Maybe some day I'll understand it)
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Submit using Perl
Next Thread in Perl Forum Timeline: What are .pm files from .pl files





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC