go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: 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 reply to Re: Extracting string from a file
by RMGir
|
|