Home » SQL & PL/SQL » SQL & PL/SQL » Oracle regular expressions query (Oracle 11.2.0.2.0)
Oracle regular expressions query [message #671350] Thu, 23 August 2018 11:15 Go to next message
jackman1
Messages: 8
Registered: August 2010
Junior Member
Hi experts,

I am not able to understand the result of the following query:
select regexp_replace('bb','a*','x') from dual;

Result:
xbxbx

Why is the regexp_replace function replacing the start and end of the string with 'x' and also inserting an 'x' in between 'b's?

I tried to search internet for articles related to boundary values etc. but could not find an explanation to what is happening here.

Any explanation/pointers or link related to the above will really help.

Thanks in advance

[EDITED by LF: applied [code] tags]

[Updated on: Fri, 24 August 2018 15:29] by Moderator

Report message to a moderator

Re: Oracle regular expressions query [message #671353 is a reply to message #671350] Thu, 23 August 2018 11:25 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

"a*" means each occurrence of 0 or more "a", event that happens at each character different from "a" in your string (the "end of string" marker counting for a "character").

Re: Oracle regular expressions query [message #671355 is a reply to message #671353] Thu, 23 August 2018 12:57 Go to previous message
jackman1
Messages: 8
Registered: August 2010
Junior Member
Thanks a lot Michel. Makes sense now.
Cheers!
Previous Topic: SQLException encounter while executing data trigger.
Next Topic: Query to group data
Goto Forum:
  


Current Time: Thu Mar 28 05:35:54 CDT 2024