Hi Gilles, Thanks for the earlier suggestion to consider Apache Commons Text for these utility methods.
After reviewing the project, I noticed that Commons Text doesn’t currently have a general-purpose utility class like `StringUtils` in Commons Lang. I’d like to ask: Would it be appropriate to introduce a new class such as `TextUtils` under the `org.apache.commons.text` package to house general-purpose text-related utility methods (like smart truncation, word counting, title casing, etc.)? Alternatively, is there an existing class where such methods would be more appropriate? Looking forward to your suggestions and guidance on this. Best regards, Kunal Bhangale On Sat, Aug 2, 2025 at 2:41 PM Gilles Sadowski <gillese...@gmail.com> wrote: > Hi. > > Le sam. 2 août 2025 à 10:55, Kunal Bhangale > <bhangalekunal2631...@gmail.com> a écrit : > > > > 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. > > Thanks for your interest in contributing to "Commons". > > > Looking forward to your feedback! > > Your proposed utilities seem better suited to [Text] than [Lang]. > Did you have a look there: > https://commons.apache.org/text > ? > > Regards, > Gilles > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > >