Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Regex Typecase

by Your Mother (Archbishop)
on Aug 14, 2007 at 06:05 UTC ( #632398=note: print w/replies, xml ) Need Help??

in reply to Regex Typecase

Quick aside for the search engines. You mean "titlecase," not "typecase." Prepositions and articles are generally not included in English so you'd want to do a hash based lookup : substitution for that. Also, given problematic abbreviations (pH) and propernames (McPerl) it's not possible to programmatically titlecase perfectly but you can get pretty close.

Replies are listed 'Best First'.
Re^2: Regex Typecase
by halley (Prior) on Aug 14, 2007 at 14:39 UTC
    The library rules for title case are even more complicated than that. I learned that you capitalize the first and last words, even if they ARE prepositions or articles. You're right in that the edge cases like apostrophes and multiple capitals (e.g., "McDonald's") are annoyingly complicated to get right.

    For my website, I have a "turn filenames into titles" function. For example, a-sunrise-to-remember.jpg becomes "A Sunrise to Remember" which uses a small canned list of the most common prepositions and articles (including a few in Spanish). Every once in a while, I find I have to add yet another special case.

    [ e d @ h a l l e y . c c ]

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://632398]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2022-12-02 12:24 GMT
Find Nodes?
    Voting Booth?