Re: show only numbers before, within or after the text
- From: sisyphus359@xxxxxxxxx (Sisyphus)
- Date: Sun, 29 Jun 2008 05:53:01 -0700 (PDT)
On Jun 29, 1:18 am, lucavi...@xxxxxxxxxxxx (Luca Villa) wrote:
I have a long text file like this:
324yellow
34house
black
54532
15m21red56
44dfdsf8sfd23
How can I obtain (Perl - Windows/commandline/singleline) the
following?
1) only the numbers at the beginning before some alpha text, like
this:
324
34
15
44
Just for fun - ie ignoring prettiness and requirements 2) and 3):
my @stuff = qw(324yellow 34house black 54532 15m21red56
44dfdsf8sfd23);
for(@stuff) {
$x = $_ * 1;
if($x == 0 && substr($_, 0, 1) ne "0") {$x = undef}
if($x eq $_) {$x = undef}
print $x, "\n" if defined $x;
}
Cheers,
Rob
.
- Follow-Ups:
- Re: show only numbers before, within or after the text
- From: Rob Dixon
- Re: show only numbers before, within or after the text
- From: Rob Dixon
- Re: show only numbers before, within or after the text
- References:
- show only numbers before, within or after the text
- From: Luca Villa
- show only numbers before, within or after the text
- Prev by Date: MIME::QuotedPrint - extra '=' and linebreak?
- Next by Date: Re: show only numbers before, within or after the text
- Previous by thread: Re: show only numbers before, within or after the text
- Next by thread: Re: show only numbers before, within or after the text
- Index(es):
Relevant Pages
|