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