in reply to regexp: extracting info
Noone clearly explained your problem, IMHO, so allow me.
1) While square brackets (as in [ee]) usually refer to optional components in BNF and command usage syntax, they mean something else in regexps. Append a question mark to make an atom (a non-special character, a character escape, something in brackets or something in parenthesis) optional (e.g. a?, (?:regexp)?). In this case, [ee] should be changed to (?:ee)?.
2) Regexps do not return captured values in a scalar context.
my $number = $str =~ /.../;
should be
my ($number) = $str =~ /.../;
3) Did you really mean to say /g? Also, /s is useless since there's no "." in your regexp.
Here are some solutions (probably already mentioned):
From the front:
/^(\w+\s+){2,3}(\d+)/
From the back:
/(\d+)\s*$/
If it's the only number:
/(\d+)/
|
|---|