Connecting Tech Pros Worldwide Help | Site Map

10g REGULAR EXPRESSIONS (REGEXP_SUBSTR)

  #1  
Old October 9th, 2007, 01:50 PM
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,188
REGEXP_SUBSTR

The REGEXP_SUBSTR function, much like the SUBSTR function, extracts part of a string

Syntax:

REGEXP_SUBSTR(source_string, pattern[, position [, occurrence[, match_parameter]]])

Example:

In the following SQL query, the string that matches the pattern , [^,]*, is returned. The regular expression searches for a comma followed by a space; then zero or more characters that are not commas, as indicated by [^,]*; and lastly looks for another comma. The pattern will look somewhat similar to a comma-separated values string.

Expand|Select|Wrap|Line Numbers
  1. SELECT REGEXP_SUBSTR('first field, second field , third field',
  2.        ', [^,]*,') reg_substr
  3.   FROM dual
  4.  
  5. REG_SUBSTR
  6. ------------------
  7. , second field   ,
  8.  



Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
what are wild cards incase of sql hardeep1 answers 4 November 26th, 2007 05:40 AM
Oracle 10g Feature: REGULAR EXPRESSIONS - 1 amitpatel66 insights 0 October 9th, 2007 01:45 PM