fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. List<String> matches = new ArrayList<String>();
  12. Matcher m = Pattern.compile("\\B#\\w*[A-Za-z]\\w*")
  13. .matcher("#test @#$#test a#test,#2021, #__");
  14. while (m.find()) {
  15. matches.add(m.group());
  16. }
  17.  
  18. System.out.println(String.join(",", matches));
  19. }
  20. }
Success #stdin #stdout 0.1s 48396KB
stdin
Standard input is empty
stdout
#test,#test