Perl Monk, Perl Meditation | |
PerlMonks |
Re: Extracting string from a fileby RMGir (Prior) |
on Nov 11, 2013 at 13:02 UTC ( [id://1061987]=note: print w/replies, xml ) | Need Help?? |
As it stands, I don't think your code even compiles, since you've got an unbalanced '(' in your regular expression. I'd start by fixing that.
Second, '|' is a special character in regular expressions, meaning "this OR that". Since you want a literal '|', you need to precede it with a '\'. Next, you're using '|' again between TOTAL and your digits, while your example has spaces there. Which is it? '\d' is a character class by itself - it doesn't go in square brackets. But since you also need to match '.', use '0-9.'. Do you also need to match negative numbers? If so, that would be '-0-9.'. Finally, you're only capturing the first number, and you said you need both. Putting all of that together, please try this regular expression: I think that might work better for you.... Test case:
Mike
In Section
Seekers of Perl Wisdom
|
|