fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.util.stream.Collectors;
  4.  
  5.  
  6. class Test
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String text = "This comment is great **[@madeUpUser1](/madeUpUser1)** You said something similar did you mate? **[@madeUpUser2](/madeUpUser2)**";
  11.  
  12. Pattern p = Pattern.compile("]\\(/([^()]*)\\)");
  13. List<String> results = p.matcher(text).results()
  14. .map(mr -> mr.group(1))
  15. .collect(Collectors.toList());
  16.  
  17. for (String x: results) {
  18. System.out.println(x);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.11s 48716KB
stdin
Standard input is empty
stdout
madeUpUser1
madeUpUser2