SORT ADDRESSES

General questions about using WildEdit

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
martib
Posts: 19
Joined: Wed Aug 23, 2006 2:28 pm

SORT ADDRESSES

Post 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
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post 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.
martib
Posts: 19
Joined: Wed Aug 23, 2006 2:28 pm

Post 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.
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post 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
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Ah, sorry! This is the WildEdit forum!

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