954,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need basic parsing/regex help

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"?

#!/usr/bin/perl
$var="BLAH{108:WHATEVER IT IS}HEY";
$parsed=($var =~ /\{108:(\w*)\}/); 
print "PARSED:$parsed\n";
winbatch
Posting Pro in Training
466 posts since Feb 2005
Reputation Points: 68
Solved Threads: 18
 
($parsed) = $var =~ /\{108:([^}]*)\}/;
KevinADC
Posting Shark
921 posts since Mar 2006
Reputation Points: 246
Solved Threads: 67
 
($parsed) = $var =~ /\{108:([^}]*)\}/;


Worked like a charm. Thanks! (Maybe some day I'll understand it)

winbatch
Posting Pro in Training
466 posts since Feb 2005
Reputation Points: 68
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You