Discussion:
Upper and lower case headache
(too old to reply)
WenAhu
2009-02-25 18:48:36 UTC
Permalink
I'm facing a rather challenging situation where I think I need help.
If I'm given an address string, I need to make sure they're showing up in our
applicaion in a proper cases, for example: If I have an address such as 123
WHATEVER AVE. SOMECITY CA 91827 (no comma) or
H123-303, WHATEVER AVE., SOMECITY, CA 91827, USA (with comma) or
similar address but all with lower case, I need to make it proper such as:
1. 123 Whatever Ave. Somecity CA 91827 OR
2. H123-303, Whatever Ave. Somecity, CA 91827, USA

Is there a way to do this?
Ian Skinner
2009-02-25 19:06:22 UTC
Permalink
Post by WenAhu
Is there a way to do this?
Yes, but not easily.

Where you have to start is to:

1) look at lots and lots and lots of different examples of the data you
expect to get.

2) The start working out the rules for how you would case the string as
desired.

3) Start to realize that these rules are going to long, complex and have
tons of exceptions.

4) Go back to whoever is paying you to do this and make sure they want
to pay you this much for some pretty formating. And suggest there is
really a reason that large organizations like the US Postal service deal
with such strings by making them ALL CAPS!

5) If they come back yes, look around to see if anybody has already
tackled this well and if you can afford their solution.

6) Start to work out your logic tree for the rules you developed.

7) Sell this to all future people who do not want to work this hard to
solve such a complex and challenging problem.
Tariq Ahmed - ACE
2009-02-25 23:13:02 UTC
Permalink
There's all kinds of "capitalize first letter of each word" functions and
scripts out there. E.g.:

http://cflib.org/index.cfm?event=page.udfbyid&udfid=889

Though in your case, you'd have to add some exception logic to not do this to
State and Country abbreviations.
simplico
2009-02-26 02:09:35 UTC
Permalink
Post by WenAhu
I'm facing a rather challenging situation where I think I need help.
 If I'm given an address string, I need to make sure they're showing up in our
applicaion in a proper cases, for example: If I have an address such as 123
WHATEVER AVE. SOMECITY CA 91827  (no comma) or
 H123-303,  WHATEVER AVE., SOMECITY, CA 91827, USA (with comma) or
 1. 123 Whatever Ave. Somecity CA 91827 OR
 2. H123-303,  Whatever Ave. Somecity, CA 91827, USA
 Is there a way to do this?
addr = lcase(text)

<p style="text-transform: capitalize;">
#addr#
</p>

Loading...