fork(1) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class RegEx {
  5. public static void main(String[] args) {
  6. String s = "<a href=\"/wiki/Computer_scientist\" title=\"Computer scientist\">computer scientist</a> <p>Its fields can be divided into a variety of theoretical and <a href=\"/wiki/Practical_disciplines\"";
  7. String r = "<p>.*?href=\"(.*?)\"";
  8. Pattern p = Pattern.compile(r);
  9. Matcher m = p.matcher(s);
  10. while (m.find()) {
  11. System.out.println(m.group(1));
  12. }
  13. }
  14. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
/wiki/Practical_disciplines