R
rpardee
Hey All,
I've got to suck some address info out of a db, where it is stored in
all caps, like so:
14 WEST 21ST ST
742 NW EVERGREEN TERRACE
PO BOX 13
And I want to pretty up the casing:
14 West 21st St
742 NW Evergreen Terrace
PO Box 13
So it's mostly just title-casing, and then dealing w/certain special
components like 'NE', 'SW', 'PO' and so forth.
I've actually got some vb.net code that I could convert, but I thought
I'd ask here whether someone's already got something they've sweated
over before I did.
Also--more concretely: for simple title-casing, is this the
easiest/best approach?
pretty_address = my_address_var.split.each do |c| c.capitalize
end.join(" ")
Or is there something more graceful/efficient?
Thanks!
-Roy
I've got to suck some address info out of a db, where it is stored in
all caps, like so:
14 WEST 21ST ST
742 NW EVERGREEN TERRACE
PO BOX 13
And I want to pretty up the casing:
14 West 21st St
742 NW Evergreen Terrace
PO Box 13
So it's mostly just title-casing, and then dealing w/certain special
components like 'NE', 'SW', 'PO' and so forth.
I've actually got some vb.net code that I could convert, but I thought
I'd ask here whether someone's already got something they've sweated
over before I did.
Also--more concretely: for simple title-casing, is this the
easiest/best approach?
pretty_address = my_address_var.split.each do |c| c.capitalize
end.join(" ")
Or is there something more graceful/efficient?
Thanks!
-Roy