fork(2) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. class Ideone
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String s = "**bold** _italic_ ~strike~ `**code**`";
  8. String regex = "(?s)`([^`]*)`|(\\*\\*|[_~])((?:(?!\\2).)*)\\2";
  9. System.out.println(s.replaceAll(regex, "$1$3"));
  10. }
  11. }
Success #stdin #stdout 0.1s 48328KB
stdin
Standard input is empty
stdout
bold  italic strike **code**