I am using the following pattern below to split the string and based on the pattern save token to an array
String[] s1=s.trim().split("[ !,?._'@]+");
I am using the following pattern below to split the string and based on the pattern save token to an array
String[] s1=s.trim().split("[ !,?._'@]+");
Regex Explaination:
[] Match any character in the set inside this.
Match a SPACE or ! or , or ? or . or _ or ' or @ character.
+ Match 1 or more (as many times as they appear) of the preceding token.
So, your code will divide the string s from at every occurance of these characters " !,?._'@" and put it into string array s1.