Replacing Middle Initial

Find, replace, find in files, replace in files, regular expressions

Replacing Middle Initial

Postby tjb24 » Fri Oct 20, 2006 11:36 pm

I'm trying to write a regualr expression to delete the middle initial in a flat file that also contains names without initials.

Example:
John C Doe
Jane Doe

Any help?
User avatar
tjb24
Newbie
 
Posts: 2
Joined: Thu Oct 19, 2006 11:00 pm

Re: Replacing Middle Initial

Postby mrainey56 » Sat Oct 21, 2006 12:51 am

These might work, depending on what other text is in your file.

Regular expression search, match case

Unix Style:
Search: ([A-Z][a-z]*) [A-Z] ([A-Z][a-z]*)
Replace: \1 \2

UltraEdit Style:
Search: ^([A-Z][a-z]+^) [A-Z] ^([A-Z][a-z]+^)
Replace: ^1 ^2
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Replacing Middle Initial

Postby tjb24 » Sat Oct 21, 2006 1:39 am

Thanks! That works perferctly. Did I mention how much UltraEdit rocks!
User avatar
tjb24
Newbie
 
Posts: 2
Joined: Thu Oct 19, 2006 11:00 pm


Return to Find/Replace/Regular Expressions