Inserting extra delimiter in CSV file with regex replace

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

Inserting extra delimiter in CSV file with regex replace

Postby quokka » Sat Sep 23, 2006 10:40 am

Hi,
I have a csv file with this setup:
"name", "address number zipcode city"

file contains 1200 rows, 2 rows from my file:
"I-Nails 4 You","Plantsoenstr 9 1441CW Purmerend Kaart / Route "
"Sylvie Nails and Manicure","G v Prinstererwg 128 2982VE Ridderkerk "

I need to put an extra delimiter before zipcode
Using search with regexp: [0-9][0-9][0-9][0-9][a-z] to search zipcode retreives 1200 results, so the expression works...

I have been trying to replace, keeping the zipcode intact and place a delimter befor it... but can't figure out how...going mad ;-)

This should be the replace result:
"I-Nails 4 You","Plantsoenstr 9","1441CW Purmerend "
"Sylvie Nails and Manicure","G v Prinstererwg 128","2982VE Ridderkerk "

Any help will be highly appreciated!!!|
Thanks for taking time to read this...
have a nice day
Quokka
User avatar
quokka
Newbie
 
Posts: 1
Joined: Fri Sep 22, 2006 11:00 pm

Re: Inserting extra delimiter in CSV file with regex replace

Postby Mofi » Sat Sep 23, 2006 11:53 am

With UltraEdit regular expression engine:

Find: +^([0-9][0-9][0-9][0-9][a-z]^)
Replace:","^1

Please note the single space before the + at start of the find string.

With Unix/Perl regular expression engine:

Find: +([0-9][0-9][0-9][0-9][a-z])
Replace:","\1

or with Unix/Perl also possible:

Find: +(\d\d\d\d[a-z])
Replace:","\1

For an explanation read in help of UltraEdit the page with title Regular Expressions.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions