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.*;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Pattern pattern = Pattern.compile("(.*)(\\/}.*\\/})");
  13. String line = "I am {check Some Text/}Middle{check Text/}";
  14. String replaced;
  15. Matcher matcher = pattern.matcher(line);
  16. if(matcher.find()) {
  17. replaced = matcher.group(1)+" is manipulated"+matcher.group(2);
  18. }else{
  19. replaced = matcher.group();
  20. }
  21. System.out.println(replaced);
  22. }
  23. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
I am {check Some Text is manipulated/}Middle{check Text/}