humanize

How to capitalize the first character of each word, or the first character of a whole string, with C#?

半世苍凉 提交于 2019-11-26 17:41:38
问题 I could write my own algorithm to do it, but I feel there should be the equivalent to ruby's humanize in C#. I googled it but only found ways to humanize dates. Examples: A way to turn "Lorem Lipsum Et" into "Lorem lipsum et" A way to turn "Lorem lipsum et" into "Lorem Lipsum Et" 回答1: As discussed in the comments of @miguel's answer, you can use TextInfo.ToTitleCase which has been available since .NET 1.1. Here is some code corresponding to your example: string lipsum1 = "Lorem lipsum et"; //

How do I convert CamelCase into human-readable names in Java?

风格不统一 提交于 2019-11-26 11:05:36
I'd like to write a method that converts CamelCase into a human-readable name. Here's the test case: public void testSplitCamelCase() { assertEquals("lowercase", splitCamelCase("lowercase")); assertEquals("Class", splitCamelCase("Class")); assertEquals("My Class", splitCamelCase("MyClass")); assertEquals("HTML", splitCamelCase("HTML")); assertEquals("PDF Loader", splitCamelCase("PDFLoader")); assertEquals("A String", splitCamelCase("AString")); assertEquals("Simple XML Parser", splitCamelCase("SimpleXMLParser")); assertEquals("GL 11 Version", splitCamelCase("GL11Version")); }

How do I convert CamelCase into human-readable names in Java?

旧城冷巷雨未停 提交于 2019-11-26 02:17:08
问题 I\'d like to write a method that converts CamelCase into a human-readable name. Here\'s the test case: public void testSplitCamelCase() { assertEquals(\"lowercase\", splitCamelCase(\"lowercase\")); assertEquals(\"Class\", splitCamelCase(\"Class\")); assertEquals(\"My Class\", splitCamelCase(\"MyClass\")); assertEquals(\"HTML\", splitCamelCase(\"HTML\")); assertEquals(\"PDF Loader\", splitCamelCase(\"PDFLoader\")); assertEquals(\"A String\", splitCamelCase(\"AString\")); assertEquals(\"Simple