I'm trying to split a String using regex with Java.
The string looks like this: {'tata','toto','titi'}
But {} describes the order of the preceding liberal, so it doesn't work for me.
What regex should I use to get this result :
tata
toto
titi
I'm trying to split a String using regex with Java.
The string looks like this: {'tata','toto','titi'}
But {} describes the order of the preceding liberal, so it doesn't work for me.
What regex should I use to get this result :
tata
toto
titi
String a = "{'tata','toto','titi'}"
a = a.replace("{'", ""); // get rid of opening bracket and singlequote
a = a.replace("'}", ""); // get rid of ending bracket and singlequote
String[] b = a.split("','"); // split on commas surrounded by singlequotes
This should give you an array of just the words you want. I guess it's not specifically regex, but it should do the right thing anyway.