Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (20 sloc) 786 Bytes
package com.levelup.groovy.string
import org.junit.Test
* This groovy example will demonstrate how to split a string with a comma as a delimiter.
* @author Justin Musgrove
* @see <a href=''>Seperate string by comma</a>
class SplitStringOnComma {
void split_string_on_comma_tokenize() {
def seperateStringByComma = "and, but, for, nor, yet, or, so".tokenize(", ")
assert ["and", "but", "for", "nor", "yet", "or", "so"] == seperateStringByComma
void split_string_on_comma_split() {
def splitStringComma = "and, but, for, nor, yet, or, so".split(", ")
assert ["and", "but", "for", "nor", "yet", "or", "so"] == splitStringComma