{"id":131,"date":"2010-07-01T17:06:49","date_gmt":"2010-07-01T21:06:49","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2010\/07\/01\/java-method-to-convert-a-string-to-proper-or-initial-case\/"},"modified":"2010-07-01T17:06:49","modified_gmt":"2010-07-01T21:06:49","slug":"java-method-to-convert-a-string-to-proper-or-initial-case","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2010\/07\/01\/java-method-to-convert-a-string-to-proper-or-initial-case\/","title":{"rendered":"Java method to convert a string to proper or initial case"},"content":{"rendered":"<p>Example: toProperCase(&#8220;hello john smith&#8221;) will return &#8220;Hello John Smith&#8221;.<\/p>\n<pre class=\"code\">\npublic static String toProperCase(String inputString) {\n\tString ret = \"\";\n\tStringBuffer sb = new StringBuffer();\n\tMatcher match = Pattern.compile(\"([a-z])([a-z]*)\", Pattern.CASE_INSENSITIVE).matcher(inputString);\n\twhile (match.find()) {\n\t\tmatch.appendReplacement(sb, match.group(1).toUpperCase() + match.group(2).toLowerCase()) ;\n\t}\n\tret = match.appendTail(sb).toString();\n\treturn ret;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This note provides a simple Java method for converting a string to have proper case, or in other words, each word will have its initial letter capitalized.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}