Spork Spork - 1 year ago 139
Java Question

Using multiple delimiters for .split in Java

Right now my code only separates words by white space, but I also want to separate by '.' and "," too. Here is my current code:

for (String words : input.split("\\s+"))

For example, if the user entered "bread,milk,eggs" or "Um...awkss" It would consider that one word, and I want each word to be it's own word.

And while I'm here, I can't get


to work either.

Answer Source

Learn more about regex since you are using it.


or just:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download