Why not drop it in an array and split it and work with it from there?  I am not sure 
what your final goal is but this way you can work with each field independently and 
check if your address_line_2 is blank.

open(FILE,$file) || die "could not open $file";
while(<FILE>) {
@data = split(/|/,$_);
....
}

-----Original Message-----
From: Balint, Jess [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 27, 2002 12:56 PM
To: '[EMAIL PROTECTED]'
Subject: Regex Help Please!?


Hello all. I am trying to 'code' an address into a certain format. The
format is as follows:

first 4 digits of street #
first 4 street name
first 2 of address line 2
first 3 of zip code

The data is a pipe delimited file with the following format:

consumer_id|address_line_1|address_line_2|zip_code|

ex:

123456789|123 s main st|apt 23|54321|

I am trying to match the needed information with a regex, but can't quite
seem to perfect it. I am running into troubles where there might not be
anything in the address_line_2 field. I want to match the first characters
up to a space. Here is what I have so far:

/^\d+\|(.+)\s(.{4}).*\|.{2}\|(.*)\|/
$code = $1 . $2 . $3 . " " . $4;
$code =~ s/\s/\$/g;

TIA.
[Jess]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to