portal entry

select a category, or use search below
(searches all categories and all time range)
Title:

Convert a string To Title Case

| View in Portal
February 18, 2019 08:49:29 PM GMT
3 Comments
<p>Convert a string To Title Case using Regular Expressions</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2019/02/convert-string-title-case/">Convert a string To Title Case</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: Blog, ColdFusion, Modern CFML, 2016, 2018, blog, modern cfml, question

Comments:

Very nice! Here's a small tweak to pick up the 1 letter words like 'I' and 'A'. <strong>titleCase = REReplaceNoCase(s, "\b(\w)(\w{0,})\b", "\U\1\L\2", "all");</strong>
Comment by CF_Ray
1672 | February 19, 2019 09:35:39 PM GMT
Good catch! I'd probably use a * instead of the {0,} but that's just personal preference.
Comment by aliaspooryorik
1671 | February 19, 2019 09:47:59 PM GMT
In Title Case you should not capitalise Articles, Conjunctions and Prepositions - unless they are the first word.
Comment by Benjamin Reid
1670 | February 20, 2019 07:12:12 AM GMT