/** * @author lautturi.com * Java example: find out the strings between quotes using regex in java */ import java.util.*; import java.util.regex.*; public class Lautturi { public static void main(String[] args) { String str = "welcome to \"lauttur! java\" world!"; Pattern p = Pattern.compile("\"([^\"]*)\""); Matcher m = p.matcher(str); while (m.find()) { System.out.println(m.group(1)); } } }
output:
lauttur! java