Here's one example of how you could go about it:

##########################

use strict;
use warnings;

my $testString = " test_freq     = 1.0001;";

print "Test One: ";
if($testString =~ /=\s*([0-9.]+)\s*;\s*$/){
    print $1;
}else{
    print "Failed!";
}
print "\n";

##########################


'[0-9.]' is a character class that represents the numbers zero through
nine and the period character.

I added in a few '\s*' matches in case there were spaces before and
after the semicolon.  This should be specific enough to match only a
number that is a n rvalue.





-----Original Message-----
From: Ryan Moszynski [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 27, 2006 1:27 PM
To: beginners@perl.org
Subject: reg ex problem

i have this string extracted from a text file i'm writing a program to
process:

 test_freq     = 1.0001;

and i have to extract the "1.0001"

i can't count on the whitspace being where it now is.

I would like to change this line of perl

 $getTestFRQ =~ s/\D+//g;

so that instead of killing all non digit characters, it will kill all
non digit characters except for the period.

How do i do this?

thanks, ryan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to