fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String regex = "(?i)\\bhemp\\.EMPLOYEE_NAME\\h*=\\h*'\\w+'\\h+(?:and|or)\\b";
  10. String string = "cond = emp.EMAIL_ID = 'xx@xx.com' AND\n"
  11. + "emp.PERMANENT_ADDR LIKE('%98n%') \n"
  12. + "AND hemp.EMPLOYEE_NAME = 'xxx' and is_active='Y'";
  13.  
  14. System.out.println(string.replaceFirst(regex, "xx$0x"));
  15.  
  16. }
  17. }
Success #stdin #stdout 0.07s 48376KB
stdin
Standard input is empty
stdout
cond =  emp.EMAIL_ID = 'xx@xx.com' AND
emp.PERMANENT_ADDR LIKE('%98n%') 
AND xxhemp.EMPLOYEE_NAME = 'xxx' andx is_active='Y'