Re: Replacing variable data between fields - Revisited.

2003-09-29 Thread perlwannabe
> Perlwannabe wrote: >> >> I originally tried to do this, but it won't work. The data doesn't >> _always_ have a before address, sometimes (although seldom) it >> has a . With grep I would miss the entire address. However, >> if I were to just select everything and replace it with nothing, that

Re: Replacing variable data between fields - Revisited.

2003-09-28 Thread John W. Krahn
Perlwannabe wrote: > > I originally tried to do this, but it won't work. The data doesn't > _always_ have a before address, sometimes (although seldom) it has a > . With grep I would miss the entire address. However, if I were > to just select everything and replace it with nothing, that would

Re: Replacing variable data between fields - Revisited.

2003-09-28 Thread perlwannabe
> Perlwannabe wrote: >> >> I posted a problem to the mailing list with a similar question I had >> some time ago regarding replacing data between fields. Unfortunately, >> I am having a difficult time with the problem. I am including the >> code and a sample of the data. Could someone please giv

Re: Replacing variable data between fields - Revisited.

2003-09-27 Thread John W. Krahn
Perlwannabe wrote: > > I posted a problem to the mailing list with a similar question I had some > time ago regarding replacing data between fields. Unfortunately, I am > having a difficult time with the problem. I am including the code and a > sample of the data. Could someone please give me a

Re: Replacing variable data between fields

2003-09-11 Thread James Edward Gray II
On Thursday, September 11, 2003, at 01:03 AM, R. Joseph Newton wrote: James Edward Gray II wrote: ... Address:2933HummingbirdSt.City:GrotonSta te :CT Address:4321SparrowAve.City:GrotonState:< ta b>CT . . . What I want to do is get all of the data between Address: and City: and strip the

Re: Replacing variable data between fields

2003-09-10 Thread R. Joseph Newton
James Edward Gray II wrote: > ... > > Address:2933HummingbirdSt.City:GrotonState > > :CT > > Address:4321SparrowAve.City:GrotonState: > b>CT > > . . . > > > > What I want to do is get all of the data between Address: and City: and > > strip the and replace with spaces. The only problem is that

Re: Replacing variable data between fields

2003-09-10 Thread James Edward Gray II
On Wednesday, September 10, 2003, at 09:20 AM, Jeff 'japhy' Pinyan wrote: On Sep 10, James Edward Gray II said: tr/\t/ /; s/(^| )([A-Za-z]+:) / length($1) ? "\t$2\t" : "$2\t" /eg; This does work on all the sample lines you provided. I'd remove the length() call, and just see if $1 is true (" ")

Re: Replacing variable data between fields

2003-09-10 Thread Jeff 'japhy' Pinyan
On Sep 10, James Edward Gray II said: >tr/\t/ /; >s/(^| )([A-Za-z]+:) / length($1) ? "\t$2\t" : "$2\t" /eg; > >This does work on all the sample lines you provided. I'd remove the length() call, and just see if $1 is true (" ") or false (""). -- Jeff "japhy" Pinyan [EMAIL PROTECTED] ht

Re: Replacing variable data between fields

2003-09-10 Thread James Edward Gray II
On Wednesday, September 10, 2003, at 12:52 AM, Alejandro Chavarria - CyPage wrote: James, If you ask the whole list your questions, you probably won't have to wait until I wake up to get an answer. ;) Why is the "tr/\t/ /;" substitution better than just using s///g;? Thanks Transliterate do

Re: Replacing variable data between fields

2003-09-10 Thread James Edward Gray II
On Tuesday, September 9, 2003, at 11:19 PM, perlwannabe wrote: On Tuesday, September 9, 2003, at 08:58 PM, perlwannabe wrote: I know it involves using the s/// operator to both strip the tabs and replace with but the problem is that it requires using an array for each address...and that is w

Re: Replacing variable data between fields

2003-09-09 Thread perlwannabe
> On Tuesday, September 9, 2003, at 08:58 PM, perlwannabe wrote: > >> I know it involves using the s/// operator to both strip the tabs and >> replace with but the problem is that it requires using an array >> for >> each address...and that is what is creating problems for me. >> >> Thanks... >

Re: Replacing variable data between fields

2003-09-09 Thread perlwannabe
>> I know it involves using the s/// operator to both strip the tabs and >> replace with but the problem is that it requires using an array >> for each address...and that is what is creating problems for me. > > > s{ (?<=Address:\t) (.+?) (?=\tCity:) } > { ( $a = $1 ) =~ tr/\t/ /; $a }ex;

Re: Replacing variable data between fields

2003-09-09 Thread John W. Krahn
Perlwannabe wrote: > > I have a text file that has various addresses in different formats. I > need to remove any items that are not part of the address so the output is > standard. Here is an example of the input file: > > Address:1234MockingbirdLaneCity:GrotonState:CT > Address:2933Hummingbir

Re: Replacing variable data between fields

2003-09-09 Thread James Edward Gray II
On Tuesday, September 9, 2003, at 09:26 PM, James Edward Gray II wrote: Hmm, let me think out loud a little. I think I see a pattern, so let's first change all of them to spaces. That's easy enough: s/\t/ /g; Obviously it was more out loud than thinking. ;) Let's change that to the better:

Re: Replacing variable data between fields

2003-09-09 Thread James Edward Gray II
On Tuesday, September 9, 2003, at 08:58 PM, perlwannabe wrote: I have a text file that has various addresses in different formats. I need to remove any items that are not part of the address so the output is standard. Here is an example of the input file: Address:1234MockingbirdLaneCity:Grot