filePro tip -- edits
Kenneth Brody
kenbrody at bestweb.net
Wed Aug 22 10:34:17 PDT 2007
I recently had someone ask me for a solution to this problem:
A file is being imported which contains a field which contains
multiple spaces between words, which need to be shrunk to a
single space.
I suggested an edit:
1space { (" " [{!" "!}]) | * }
It turned out that the field was a name field, and was actually
in last name, first name format, and it needed a comma after the
last name. Unfortunately, the names themselves may contain
spaces, so inserting a comma before the first space is not an
option. (Also, the first name did not always start in the same
column, so MID was not an option, either.)
The following will insert a comma before any set of multiple
spaces, and condense any whitespace to a single space:
ln_fn { {!" "!}@ | ( <, > !" "! [{!" "!}] ) | * }
I leave it as an exercise for the reader to determine why this edit
needs the {!" "!}@ at the beginning. Bonus points for answering
correctly without actually testing the edit without it. :-)
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap at gmail.com>
More information about the Filepro-list
mailing list