fork(22) download
  1. import java.util.*;
  2. import java.io.*;
  3. import java.util.regex.*;
  4. import java.util.List;
  5.  
  6. class Program {
  7. public static void main (String[] args) throws java.lang.Exception {
  8.  
  9. String subject = "audio*2012*.wav";
  10. Pattern regex = Pattern.compile("[^*]+|(\\*)");
  11. Matcher m = regex.matcher(subject);
  12. while (m.find()) {
  13. if(m.group(1) != null) m.appendReplacement(b, ".*");
  14. else m.appendReplacement(b, "\\\\Q" + m.group(0) + "\\\\E");
  15. }
  16. m.appendTail(b);
  17. String replaced = b.toString();
  18. System.out.println(replaced);
  19. } // end main
  20. } // end Program
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
\Qaudio\E.*\Q2012\E.*\Q.wav\E