There are other posts I know, but they aren’t about java.
What I’m asking for is a way to check if a string contains a word that is longer than 56 characters. I want then to insert a ” ” inside the word(probably in the middle). I want the spaces in the original string to remain there.(split(” “) doesn’t help me because of that).
There are other posts I know, but they aren’t about java. What I’m asking
Share
assuming, of course, your definition of “word” matches Pattern’s definition of “word character”:
[a-zA-Z_0-9]To unpack, that just looks for 56 or more consecutive word characters.
If you liked, you could even hold on to the
Matcherobject, which would let you get thestart()andend()of the 56+ letter word.