Difference between revisions of "Regular Expressions"

From dbawiki
Jump to: navigation, search
(Created page with "Oracle can do almost as much as Perl but it's not quite there yet! Select a piece out of a long filename: <pre> string := '/oracle/export/MOCMMSP2/expdp_DEV2_D_FULL_201301312...")
 
 
Line 16: Line 16:
 
</pre>
 
</pre>
 
This will pick out the date part of the filename.
 
This will pick out the date part of the filename.
 +
 +
====References====
 +
[[http://www.oracle-developer.net/display.php?id=508 oracle-developer.net]]

Latest revision as of 14:35, 12 February 2013

Oracle can do almost as much as Perl but it's not quite there yet!

Select a piece out of a long filename:

string := '/oracle/export/MOCMMSP2/expdp_DEV2_D_FULL_20130131210003_01.dmp.gz';

SELECT REGEXP_SUBSTR(
,      string,
,      '(\_)([0-9]+)(\_)'   --<-- expression with subexpressions
,      1                    --<-- starting position
,      1                    --<-- nth occurrence
,      'i'                  --<-- match parameter (ignore case)
,      2                    --<-- 11g: subexpression to return
,      )
FROM   dual

This will pick out the date part of the filename.

References[edit]

[oracle-developer.net]