fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Pattern;
  5. import java.util.regex.Matcher;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String thread = "From: Demo Name\n" +
  12. "Sent: Wednesday, January 18, 2023 2:56 PM\n" +
  13. "To: demo@myweb.com <demo@myweb.com>\n" +
  14. "Subject: Demo Issue";
  15. String regEX = "^From:\\h+.+\\RSent:\\h+.+\\RTo:\\h+.+\\RSubject:\\h+.*";
  16. Pattern pattern = Pattern.compile(regEX, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
  17. Matcher matcher = pattern.matcher(thread);
  18. System.out.println(matcher.find());
  19. }
  20. }
Success #stdin #stdout 0.09s 48300KB
stdin
Standard input is empty
stdout
true