import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String args[]) { String s = ""; s += ""; s += ""; s += "\n"; s += "\n"; s += "\n"; s += ""; s += "
取り出したい文字列1取り出したい文字列2取り出したい文字列3
"; String pt = "(.+?)"; Pattern p = Pattern.compile(pt); String st; BufferedReader br = new BufferedReader(new StringReader(s)); try { while ((st = br.readLine()) != null) { Matcher m = p.matcher(st); if (m.find()) { System.out.println("Match"); System.out.println(m.group(1)); } } } catch (IOException e) { throw new RuntimeException(e); } } }