in reply to Splitting two digits
If you want to split exactly two digits apart you could do:
my @field; if ($text =~ /^(\d)(\d)/) { @field = ($1, $2); }
This regex will find two (0-9) digit characters at the beginning of a string and save them to $1 and $2. If there is a match, the values will be assigned to the array @field. There's probably a more efficient way to do a split on digits only.
It's also worth noting that the previous suggestions are more flexible.
--
Grant me the wisdom to shut my mouth when I don't know what I'm talking about.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Splitting two digits
by cored (Scribe) on Jan 08, 2003 at 03:33 UTC | |
by Ionizor (Pilgrim) on Jan 08, 2003 at 03:57 UTC |