fork(1) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class rTest {
  5. public static void main (String[] args) {
  6.  
  7.  
  8. String s = "This is a test [url] http://w...content-available-to-author-only...m.hk [/url]\n"
  9. + " and [img] http://w...content-available-to-author-only...c.com/test.png [/img]";
  10.  
  11. Pattern p = Pattern.compile("\\[[^\\]]*\\]([^\\]]*)\\[[^\\]]*\\]");
  12. Matcher m = p.matcher(s);
  13. while (m.find()) {
  14. System.out.println(m.group(1).trim());
  15. }
  16.  
  17.  
  18. }
  19. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
http://w...content-available-to-author-only...m.hk
http://w...content-available-to-author-only...c.com/test.png