Reputation: 62664
As the question states, how to form a regular expression so that it "splits" on everything that is a non-word character with 0 or more trailing or leading whitespace?
So:
String a= Hello. My name is "Jello" What is your name?
a.split("expression")
Becomes...
[Hello, My, name, is, Jello, What, is, your, name]
Upvotes: 0
Views: 96
Reputation: 79847
You want
a.split("\\W+")
as described in the Javadoc for Pattern. - \W
is any non-word character and +
means "one or more".
Upvotes: 1