1

I want to replace ALL ', with '|| .However, I only replace ', that show up after the very first word begin (case insensitive). We might have multiple BEGIN, but once I meet the word begin for the first time, I want to replace all occurrences AFTER begin.

Here is my code that replaces ALL without exception:

regexp_replace(column_name, ''',', '''||', 1, 0, 'i');

Thanks

1
  • Dear Qanat Tajrediat, you should considering update your work according to the editted answer.. Commented May 26, 2016 at 2:44

1 Answer 1

2

You could simply find the position of the first word begin in your column and add to position parameter of regexp_replace

So you should use this

regexp_replace(column_name, ''',', '''||', regexp_instr(column_name, '\sbegin\s', 1, 1, 0, 'i'), 0, 'i');

Editted: According to suggestion from Gary_W, you should consider using keyword '\sbegin\s' (updated in above code) to avoid finding wrong word when begin is part of another word like function get_beginning_status.

P/S: Using \s instead of non-breaking-space in case string text in column_name have line break

Sign up to request clarification or add additional context in comments.

1 Comment

You might want to add a space either side of BEGIN in case the string 'BEGIN' is part of another word.

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.