I have a string like this x=y AND z=y AND p=q
, I need to replace every (space)AND(space)
pattern with *
so that the original string turns into x=y*z=y*p=q
. I'm using Regular expression
for this cause the important thing is that there might by more that one space before and after each AND
.
I've written two different queries for this
query1:
select regexp_replace('x=y AND z=y AND p=q','[[:space:]]AND[[:space:]]','*')
from dual;
query2:
select regexp_replace('x=y AND z=y AND p=q', '\s+AND\s+', '*')
from dual;
I want to know :
- Are there better ways to do that?
- What is the main difference between these two queries? I mean
[[:space:]] and \s
? The important thing is that I want to know In what sort of condition these two queries will produce different result?
Thanks in advance