I'm trying to parse thousands of Oracle SQL script WHERE clauses.
I want to replace the keyword user (as in the person currently logged in) with something else. I can't just do a replace all as user may be used as part of another word in the where clause like a column name, for example, payuser. And I can't simply check is there whitespace on either side of it as it could be inside a bracket or have an equals sign next to it or some other mathematical character.
where (username = user or admin = user) and loggedIn=user order by pay_group_code;
public class TestClass{
public static void main(String []args){
String where = "where (username = user or admin = user) and loggedIn=user order by pay_group_code;";
where = where.replaceAll("\buser\b", "test");
System.out.println(where);
}
}