Re: Adding ID numbers to names

2006-03-02 Thread Chas Owens
What you need is Regexp::List (http://search.cpan.org/dist/Regexp-Optimizer/lib/Regexp/List.pm). It will take a list of strings and produce an optimal regex to find those strings. You can then use a hash in the replacement to map to the right key. For example, the list Chas Owens, John Smith, Jo

Re: Adding ID numbers to names

2006-03-02 Thread Ash Varma
On 3/3/06, Ryan Gies <[EMAIL PROTECTED]> wrote: > > Ash Varma wrote: > > > > Any hint on the J Smith and J Smith Thomas ?? > > > > Hmm, good point. I'm sure there are several methods, but the first > which comes to mind is to do two replacements... > > a. sort you list by the length(), processing

Re: Adding ID numbers to names

2006-03-02 Thread Ryan Gies
Ash Varma wrote: Any hint on the J Smith and J Smith Thomas ?? Hmm, good point. I'm sure there are several methods, but the first which comes to mind is to do two replacements... a. sort you list by the length(), processing longer names first b. 1st replacement replaces the all names with

Re: Adding ID numbers to names

2006-03-02 Thread Ash Varma
On 3/3/06, Ryan Gies <[EMAIL PROTECTED]> wrote: > > > for ($i=0;$i<=$#id;$i++) { > > $randomtext =~ s/$name[$i]/$name[$i] $id[$i]/g > > } > > Putting the word-break identifiers around your search text will prevent > "J Smithers" from getting replaced when the $i for "J Smith" comes around. > >

Re: Adding ID numbers to names

2006-03-02 Thread Ryan Gies
for ($i=0;$i<=$#id;$i++) { $randomtext =~ s/$name[$i]/$name[$i] $id[$i]/g } Putting the word-break identifiers around your search text will prevent "J Smithers" from getting replaced when the $i for "J Smith" comes around. $randomtext =~ s/\b$name[$i]\b/$name[$i] $id[$i]/g -- To unsu

Re: Adding ID numbers to names

2006-03-02 Thread Ash Varma
On 3/3/06, Wagner, David --- Senior Programmer Analyst --- WGO < [EMAIL PROTECTED]> wrote: > > Ash Varma wrote: > > Hi.. > > > > I have 2 files of data.. > > > > File 1 = id,name > > > > eg: > > > > 0001, J Smith > > 0002, J Smithers > > 0003 J Smith Thomas > > > > > > File 2 = general text, with n

RE: Adding ID numbers to names

2006-03-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Ash Varma wrote: > Hi.. > > I have 2 files of data.. > > File 1 = id,name > > eg: > > 0001, J Smith > 0002, J Smithers > 0003 J Smith Thomas > > > File 2 = general text, with names recorded at different locations.. > > eg. > > This is random text for with J Smith, J Smithers and J Smith Tho

Adding ID numbers to names

2006-03-02 Thread Ash Varma
Hi.. I have 2 files of data.. File 1 = id,name eg: 0001, J Smith 0002, J Smithers 0003 J Smith Thomas File 2 = general text, with names recorded at different locations.. eg. This is random text for with J Smith, J Smithers and J Smith Thomas I am trying to replace all J Smiths with J Smith