java pattern matching group inside the other

I am trying to extract blocks that start with “CREATE PROCEDURE name AS” and ends with “GO;”. so I coded that as follows: String pat=”(?s)create\\s+procedure\\s+\\w+\\s+as.+go\\s*;”; String str=”some text create procedure name as body go; some text create procedure anothername as body go;”; Pattern p=Pattern.compile(pat,Pattern.CASE_INSENSITIVE); Matcher m=p.matcher(str); while(m.find()) System.out.println(m.group()); this code returned (one string): “create procedure…

Details