DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Perl (http://www.daniweb.com/forums/forum112.html)
-   -   Need basic parsing/regex help (http://www.daniweb.com/forums/thread72282.html)

winbatch Mar 13th, 2007 8:22 pm
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";

KevinADC Mar 13th, 2007 8:47 pm
Re: Need basic parsing/regex help
 
($parsed) = $var =~ /\{108:([^}]*)\}/;

winbatch Mar 13th, 2007 10:14 pm
Re: Need basic parsing/regex help
 
Quote:

Originally Posted by KevinADC (Post 329066)
($parsed) = $var =~ /\{108:([^}]*)\}/;

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


All times are GMT -4. The time now is 2:59 am.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC