DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Java: RegEx: Splitting A Space-, Comma-, And Semi-colon Separated List
// Greedy RegEx quantifier used
// X+ = X, one or more times
// [\\s,;]+ = one or more times of either \s , or ;
String test_data = "hello world, this is a test, ;again";
_logger.debug("Source: " + test_data);
for (String tag : test_data.split("[\\s,;]+"))
{
_logger.debug("Received tag: [" + tag + "]");
}




