Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Text: Add Capitalize method under WordUtils #8

Closed Kalkwst closed 1 year ago

Kalkwst commented 1 year ago

The code above capitalizes the first character of each word in a string. If a list of delimiters is provided, the code will use those delimiters to determine where each word starts. If no delimiters are provided, it will default to using space characters as delimiters. The code first checks if the input string is null or empty, and if it is, it returns the input string. It then creates a set of delimiters and a StringBuilder to store the modified string. It iterates through each character in the input string, checking if it is a delimiter or if it should be capitalized. If it is a delimiter, it sets a flag to indicate that the next character should be capitalized. If the character should be capitalized, it capitalizes it and unsets the flag. If the character should not be capitalized, it is appended to the StringBuilder as is. Finally, the modified string is returned.