Franklin wrote:

> Hello:
> I want to extract the digit from a line of text. For exmple, for a
> text line: TSC2101Net, how can I write a script to extract 2101 and
> print it?
> Thank you very much in advance!
> Bestwishes
> Franklin
>
>       
>       
>
> ____________________________________________________
> <http://www.incredimail.com/redir.asp?ad_id=309&lang=9> /IncrediMail/
> - *Email has finally evolved* - *_Click Here_*
> <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>

try this [take your own risk :) ] :

******cut here*****************
#!/usr/bin/perl
#

$bannerkoe=<<END
Tes regex
:))

END
;
print "$bannerkoe";

$phile="tes_regex2.txt";

open(FH, $phile) || die("Cannot open the file");
@fh=<FH>;

foreach $bingung(@fh) {
@pecah=split/ /,$bingung;
foreach (@pecah) {
@kar=split//,$_;
foreach $elemen(@kar) {
$hasil=$elemen=~m/(\d+)/;
if ($hasil) {print "$elemen";}
}
}
print "\nasalnya : $bingung\n";
}

close(FH);
****cut here**********

the content of tes_regex2.txt :
aku tes aja ya...
TSC2101Net
:)



Iko Riyadi
Departemen Data Manajemen
PT. Infomedia Nusantara
Jl. Kusuma Bangsa 10-12
Surabaya 60272 Indonesia
Telp: +62 (031) 5326282, Fax: +62 (031) 5343613
http://www.yellowpages.co.id

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to