fork download
  1. /* package whatever; // don't place package name! */
  2. import java.util.regex.Matcher;
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.Pattern;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String content = "<A HREF='/articles/0,7340,L-4664450,00.html' CLASS='whtbigheader' style='color:#FFFFFF;' HM=1>need to get this value</A>";
  13. Pattern p = Pattern.compile("(?i)<A.+?class\\s*?=(['\"])?(?:whtbigheader)\\1[^>]*>(.*?)</A>");
  14. Matcher m = p.matcher(content);
  15.  
  16. if (m.find()) {
  17. System.out.println("found");
  18. System.out.println(m.group(2));
  19. }
  20. else {
  21. System.out.println("not found");
  22. }
  23. }
  24. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
found
need to get this value