I'm trying to create a program that will split a given string into multiple parts, then convert all to lowercase if it has two or more consecutive capital letters. After splitting the string, it would strip it of any non-alphabetical characters, convert it all to lowercase, then put the non-alphabetical characters back in. I have the logic to convert it all to lower case, but it doesn't split the string quite how I want. Currently, I'm trying to make it so that it:
- Splits the string where there are two or more consecutive capital letters, then makes it all lowercase (THIS_IS_A_TEST)
- Splits the string where there is a "!", "?", or "." (THIS.IS!A?TEST)
- Splits the string where there is whitespace (THIS IS A TEST)
I currently here's everything I have to do this stuff: http://pastebin.com/ppBykvY4
Where the "[A-Z]{2}" is for two consecutive capitals, but I don't know how I can include the rest. {Punc} would only work if I could exclude everything except "!", "?", ".".
Also, I'm using the BukkitAPI.
EXAMPLE: If a user entered all of the above examples (in the bullets), they should be:
- this_is_a_test
- this.is!.a?test
- this is a test

split("[A-Z]{2}")does what you expect? What it acutally does is use any two groups of capital letters as a delimiter. E.g. for the following string:I LIke to eat pizza in LA. And drink wine in Detroit, the splits will be:I,ke to eat pizza inand. And drink wine in Detroit.I like to eat pizza in la. And drink wine in detroit.