in reply to Regex to take an ip address before a comma
Assigns everything up to the first comma to $first:
my ($first) = $str =~ /(.*?),/;
Not as efficient, but possibly more readable:
my ($first) = split(/,\s*/, $str);
Update: D'oh! Fixed bug mentioned in reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex to take an ip address before a comma
by moritz (Cardinal) on Nov 25, 2008 at 15:49 UTC | |
|
Re^2: Regex to take an ip address before a comma
by linuxer (Curate) on Nov 25, 2008 at 16:30 UTC | |
by linuxer (Curate) on Nov 25, 2008 at 16:43 UTC | |
by ikegami (Patriarch) on Nov 25, 2008 at 17:57 UTC | |
by moritz (Cardinal) on Nov 25, 2008 at 18:13 UTC | |
by ikegami (Patriarch) on Nov 25, 2008 at 19:07 UTC |