-1 for findAllOccurrences, just not useful enough -1 for isTitleCase, just not useful enough.
toTitleCase is useful but needs a Locale. toTitleCase(String str,Locale locale). This is much harder to implement correctly than most people expect. A naive and obvious implementation will be incorrect. -10 for smartTruncate. Very uncommonly needed and unlikely to do what is needed in a specific case. -1 to removeRepeatedCharacters. just not commonly enough needed, if it ever is countWords is a maybe, but again this is a lot trickier than it looks, especially once you start considering languages that don't separate words with spaces. The algorithm is locale dependent. Also note: real world use cases means actual code in verifiable projects that already perform these operations and might replace them with an Apache commons implementation. That is, point to file and line number of projects that have already implemented this and could benefit from a more complete, better supported implementation. Hypothetical examples are not real world use cases. On Sat, Aug 2, 2025 at 8:55 AM Kunal Bhangale <bhangalekunal2631...@gmail.com> wrote: > > Hi Commons Lang Developers, > > I would like to propose the addition of some new utility methods to > `StringUtils` in Apache Commons Lang. These methods are commonly needed in > real-world projects but currently not available in the library. > > Here are some initial ideas: > > > 1. *findAllOccurrences(String str, String subStr)* > - Description: Returns a list of all indexes where a substring occurs in > the main string. > - Example: findAllOccurrences("abcabc", "a") → [0, 3] > > 2. *toTitleCase(String str)* > - Description: Converts each word's first character to uppercase and the > rest to lowercase. > - Example: toTitleCase("hello world") → "Hello World" > > 3. *smartTruncate(String str, int maxLength)* > - Description: Truncates the string to the nearest full word under the > limit and appends "..." if needed. > - Example: smartTruncate("This is a long sentence", 10) → "This is..." > > 4. *removeRepeatedCharacters(String str)* > - Description: Removes consecutive duplicate characters. > - Example: removeRepeatedCharacters("aaabbbcccaaa") → "abca" > > 5. *isTitleCase(String str)* > - Description: Checks if the input is in title case format. > - Example: isTitleCase("Hello World") → true > > 6. *countWords(String str)* > - Description: Returns the number of words in the input string. > - Example: countWords("Apache Commons Lang") → 3 > > > I’d be happy to implement these methods and write appropriate JUnit tests. > If the community finds these valuable, I can create a JIRA issue and start > working on the patch. > > Looking forward to your feedback! > > Thanks & Regards, > Kunal Bhangale > bhangalekunal2631...@gmail.com -- Elliotte Rusty Harold elh...@ibiblio.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org