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

Reply via email to