Search code examples
sqloracle-databaseoracle11gregexp-replace

Oracle regexp_replace default replace string


I have a simple question I cant find the answer for:

Is this:

regexp_replace(somecolumn, someregex) 

The same as the following?

regexp_replace(somecolumn, someregex, NULL) 

Solution

  • Yes, they're the same. The documentation for REPLACE is more explicit about this behavior:

    If replacement_string is omitted or null, then all occurrences of search_string are removed.

    But REGEXP_REPLACE behaves the same way. The third argument replace_string replaces whatever matches the pattern; if it's omitted or null, all matching parts of the string are removed.