in reply to parse a string
\s matches a space character. (\S+) matches one or more non-whitespace characters, and captures them. $ matches the end of line. Be sure to pay attention to whether your string has a newline at the end or not, and remove it or match for it as appropriate.my $string = "something, something, something, this"; my ($lastword) = $string =~ /\s(\S+)$/;
You could also use split(), but I'll leave that one for someone else.
Alan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) 2Re: parse a string
by jeffa (Bishop) on May 03, 2002 at 15:13 UTC |