0

I am searching for a pattern "hello world" and replaced with Hello Bob.

Here I want to match all patterns of hello world. The problem is that we cannot match both patterns in replace function. so I make it lower and replacing.

As a Result , It making the whole string as lowercase. "this is Hello Bob program!. this is Hello Bob program"

But I want it as "This is Hello Bob Program!. This is Hello Bob Program"

This is the query: select replace(lower('This is Hello World Program!. This is hello world Program'),lower('Hello world'),'Hello Bob') from dual;

Any suggestion please

1 Answer 1

6

You are receiving your result in all lower case because you are performing the LOWER function on your source string. Instead of using REPLACE, you can use REGEXP_REPLACE since that function has the ability to ignore case sensitivity.

SELECT REGEXP_REPLACE ('This is  Hello World Program!. This is hello world Program',
                       'Hello world',
                       'Hello Bob',
                       1,
                       0,
                       'i')
  FROM DUAL;
Sign up to request clarification or add additional context in comments.

5 Comments

Can you pls explain, why 1 and 0 are passing there
Why wouldn't you, @Yash, read documentation EJ posted? It explains everything.
@Yash - those are the default values for the position and occurrence arguments, as shown in the documentation EJ linked to; as they are defaults they can usually be omitted, but as these are positional parameters you have to supply values for those in order to be able to supply a value for the match_param argument.
If you click on the link I had provided, it has the documentation for each of the parameters. 1 is the position of the string to start searching and the 0 is which occurrence to replace. 0 means all occurrences.
Apologize I missed that.. Thank you all for your responses. I got that. Once again Thank you so much for your time to helping me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.