Umar Draz wrote:
> Dear User!
> 
> I want to get all telephone and mobile number from a string and save into a 
> variable. Here is my example what i am doing.
> 
> #!/usr/bin/perl
> 
> $str = "This is my string my mobile number is 0300-4459899, 042-8494949 
> 041-8580880 now the string is complete"
>  while($line =~ /(([0-9]{3,4}[-]?)?[0-9]{7})/g){
>    $tel =  $1
> }
> 
> Now the above code is working file for me all telephone numbers and mobile 
> number are saved in $tel. 
> 
> No my question is how to handle spaces e.g

If you are just throwing away everything but the numbers:

my $str
> = "This is my string my mobile number is 042-6715171 0 30 0- 4 4 5 9 8
> 9 9,  0 42-84 94 94 9, 0 4 1 - 85 80  8 8 0 now the string is complete";

$str =~ s/\s+//;

> while($line =~ /(([0-9]{3,4}[-]?)?[0-9]{7})/g){
> 
>    $tel =  $1
> 
> }

Steve

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to