// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.regex.Pattern;

public class InsideBody {
    private static final Pattern restart = Pattern.compile(".*<body[^>]*>", Pattern.DOTALL);
    private static final Pattern reend = Pattern.compile("</body>.*", Pattern.DOTALL);
    public static void main(String[] args) {
        String html = "<html>\r\n<head>\r\n<title>hej</title>\r\n</head>\r\n<body style=\"color: red;\">\r\n<div>mojn</div>\r\n<i>mojn mojn</i>\r\n</body>\r\n</html>";
        System.out.println(html);
        String inside1 = html.replaceAll(".*<body[^>]*>", "").replaceAll("</body>.*", "");
        System.out.println(inside1);
        String inside2 = reend.matcher(restart.matcher(html).replaceAll("")).replaceAll("");
        System.out.println(inside2);
    }
}
