Database Reference
In-Depth Information
14.2.3
Using Regular Expressions
The following example uses REGEXP_INSTR to find the position of all
song titles containing a capital letter A. The result is shown in Figure 14.3.
COLUMN TITLE FORMAT A32
SELECT TITLE, VAL FROM(SELECT TITLE
,REGEXP_INSTR(title, 'A(/*)') AS VAL FROM SONG
) WHERE VAL > 0;
The following SQL code statement would find the same result as that in
Figure 14.3.
SELECT TITLE FROM SONG WHERE TITLE LIKE '%A%';
Where the INSTR (REGEXP_INSTR) function retrieves the position
of a string, the SUBSTR (REGEXP_SUBSTR) function retrieves a por-
tion of a string. The following script will retrieve the second occurrence of
every song title where the string is enclosed by spaces. Therefore, a string
Figure 14.3
REGEXP_INSTR
and Finding the
Position of All Song
Titles Containing
the Letter A.
 
Search WWH ::




Custom Search