Hello,
I believe what you want to use is the substr function, as follows:
$variable = substr($line, 4, 9);
That would return the characters from 4 to 9 in the variable $line.
Robert Aspinall
Support Engineer
V-ONE Corporation
[EMAIL PROTECTED]
----- Original Message -----
From: "Govinderjit Dhinsa" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 10:08 AM
Subject: RE: REGEX
> Hi, can any body help me with a regex problem that I have please!
> #########################################
> Q. Could any body please show me how to, print data by searching
> character Numbers in a input line!
> #########################################
> I have a input file, below is a few *LINES* of example of the input
> file:
>
> 168127407932117187M000001080m200107035eN/A
> 168148007947033647M200107015m2100000000n/a
>
> 168149807947023347M000200107m0000034500n/a
> 168150607947058268M200107015y13 00000000n/a
> #######################################################
> For each *line* of the input file I need to get certain sets of data
> in the line (string), for example;
> 0 to 5 (characters), 8 to 12 (characters), 14 to 16 (characters on
> each line)
>
> *I can only search by specifying numbers* as there is no, spaces,
> tabs and etc, to separate the fields that I require!
>
> ########################################################
> Here is a programme that I wrote in the past to search for Fields,
> as there was tab spaces in-between the input file, fields. I would like to
> modify this programme to do what I need, however I can not use this as
there
> is no tab spaces to separate the fields in the input file!
>
> open iscd,"<$ARGV[0]" or die "Cannot open $ARGV[0]",$!;
> open sortcode,">$ARGV[1]";
> while($line=<iscd>){
> chomp $line;
> @fields=split "\t",$line;
> printf sortcode "\n%6.6s%8.8s%27.27s%35.35s%35.35s",
>
> $fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields[6];
> }
> close iscd;
> close sortcode;
> exit;
> #######################################################
>
> Any help would be much appreciated.
>
> Kind Regards
> GD