fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String searchText = "abcd erhjr @@_dhsdj_@@ dshdgj andaj edwyhu @@_dgayw_@@ nssd.";
  11. List<String> result = new ArrayList<>();
  12. Matcher m = Pattern.compile("@@_\\S*?_@@").matcher(searchText);
  13. while (m.find()) {
  14. result.add(m.group(0));
  15. }
  16. System.out.println(result);
  17. }
  18. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
[@@_dhsdj_@@, @@_dgayw_@@]