Page 1 of 1

SORT ADDRESSES

Posted: Wed Sep 13, 2006 12:42 pm
by martib
hi,

i want to sort addresses and split them. a line looks like:

Acmelake Road 104 80741 Funkytown

Now I want to split before and after the Zip Code which is always 5 digits.
So the result should be:

Acmelake Road 104|80741|Funkytown

Thanks,
Marti

Posted: Wed Sep 13, 2006 2:35 pm
by SteveH
I'm not completely sure what you want to use to replace the spaces but the following should be a starter.

With regular expressions enabled in the search and replace dialog, you need to search for the following string:
([0-9]{5})
Please note the spaces here either side of the (). Use the following replacement expression.
|\1|
This will search for the 5 character number sourrounded by spaces, creating a back reference for the 5-digit character found. \1 in the replacement expression is used to replace the number found.

Hope this helps.

Posted: Fri Sep 15, 2006 10:25 pm
by martib
hi steve,

no. does not work, as it replaced the zip codes.
how can i keep the 5 digits?


i want to pipe-separate the lines to use as ascii database.

Posted: Sat Sep 16, 2006 11:26 am
by SteveH
What did it replace the zip code with? When I run this search and replace (albeit not in TextPad) I get the following:
104 12345 Lazytown
becomes...
104|12345|Lazytown

Posted: Sun Sep 17, 2006 9:51 am
by ben_josephs
Martib: There is no need to double-post.

From what you say, it appears that you've selected Regular expression in the Replace dialogue box, and you're using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Otherwise, the regular expression Steve offered you wouldn't have matched at all.

His suggestion definitely works. Please try it again and check your typing carefully.

As for your other request, to match strings of digits with embedded spaces, such as 193 00 (which are not ZIP codes), this will do that:
([0-9]{3} [0-9]{2}) or ([0-9][0-9][0-9] [0-9][0-9]) (with a space at the beginning and at the end).
To catch ZIP codes with or without the improper space, use this:
([0-9]{3} ?[0-9]{2}) or ([0-9][0-9][0-9] ?[0-9][0-9]) (with a space at the beginning and at the end).

But you haven't provided enough information for us to be sure we're catching the ZIP codes and only the ZIP codes.

Posted: Sun Sep 17, 2006 1:54 pm
by ben_josephs
Ah, sorry! This is the WildEdit forum!

For WildEdit, the replacement expression should be
|$1|
instead of
|\1|
.