import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String regex = "(?i)\\bhemp\\.EMPLOYEE_NAME\\h*=\\h*'\\w+'\\h+(?:and|or)\\b";
        String string = "cond =  emp.EMAIL_ID = 'xx@xx.com' AND\n"
	 + "emp.PERMANENT_ADDR LIKE('%98n%') \n"
	 + "AND hemp.EMPLOYEE_NAME = 'xxx' and is_active='Y'";
	 
        System.out.println(string.replaceFirst(regex, "xx$0x"));

	}
}