Connecting Tech Pros Worldwide Forums | Help | Site Map

10g REGULAR EXPRESSIONS (REGEXP_REPLACE)

amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,216
#1   Oct 9 '07
REGEXP_REPLACE

This function replaces the matching pattern with a specified replace_string, allowing complex search-and-replace operations.

Syntax:

REGEXP_REPLACE(source_string, pattern[, replace_string [, position[,occurrence, [match_parameter]]]])

Example:

The following query replaces any two or more spaces with a single space. The ( ) subexpression contains a single space, which can be repeated two or more times, as indicated by {2,}.

Expand|Select|Wrap|Line Numbers
  1. SELECT REGEXP_REPLACE('Joe   Smith',
  2.        '( ){2,}', ' ')
  3.        AS RX_REPLACE
  4.   FROM dual
  5.  
  6. RX_REPLACE
  7. ----------
  8. Joe Smith 
  9.  



Closed Thread