ArrayList<String> text = new ArrayList<String>(Arrays.asList(s.split("[ !,?._'@]+")));
Can anyone explain what this '+' sign after the square brackets in the split method used for?
ArrayList<String> text = new ArrayList<String>(Arrays.asList(s.split("[ !,?._'@]+")));
Can anyone explain what this '+' sign after the square brackets in the split method used for?
In regular expressions, +
means "one or more". In your case, the split
method will slice your string when it finds one or more occurences of the symbols inside the square brackets.
it is means "One or more" symbols. Example:
const str = '100dfsdfds00';
str.match(/[a-z]/g) // [d, f, s...]
str.match(/[a-z]+/g) // [fsdfds]