How I can get fr and en from ["fr", "en"] using regex?
I have tried to use split("[\\W]+") but it gives me 3 items ("", "fr" and "en").
How can I do this without getting that first empty string, and just get fr and en?
Instead of split you should use this regex to match the desired parts:
(?<=")\w+(?=")
In Java:
String str = "[\"fr\", \"en\"]";
Pattern p = Pattern.compile("(?<=\")\\w+(?=\")");
Matcher = p.matcher(str);
while (m.find())
System.out.println(m.group());
Output:
fr
en