1)REGEXP example01
1@@@@a glance of REGEXP
@@@
@@@<1>'*the*' => vague search all line.
@@@
[oracle@station78 ~]$ sqlplus / as sysdba;
SYS@ocp> CREATE TABLE t_regexp (chardata varchar2(50));
Table created.
SYS@ocp> INSERT INTO t_regexp VALUES('A theory concerning');
1 row created.
SYS@ocp> INSERT INTO t_regexp VALUES('the origin of the universe, is the Big');
1 row created.
SYS@ocp> INSERT INTO t_regexp VALUES('Bang.');
1 row created.
SYS@ocp> commit;
Commit complete.

@@@
@@@usage: regexp_like(column_name, condition)
SYS@ocp> SELECT * FROM t_regexp WHERE REGEXP_LIKE(chardata,'*the*');
CHARDATA
------------------------------------------------------------------
A theory concerning
the origin of the universe, is the Big


@@@
@@@<2>'^the' => the start of line.
@@@
regexp_like(search_string, pattern_string, match_parameter)
match_parameter:
  'i' case-insensitive matching
  'c' case-insensitive matching
  'm' allows the period '.' to match the new line character
  'n' allows the search_string to represent or contain multiple lines

@@@search the 'the' occurs only at the start of line.
SYS@ocp> SELECT * FROM t_regexp WHERE REGEXP_LIKE(chardata,'^the*');
CHARDATA
--------------------------------------------------
the origin of the universe, is the Big


@@@
@@@<3>[Yy] {1}B.{1}g single character.
@@@
Note:
    combine the use of the '.' to match any single character with '{}' repetition
  catability, here I find a single character between 'B' and 'g' and exactly two
  characters between the 'B' and 'g'.
     using [abcd] match an any single characters.
SYS@ocp> SELECT * FROM t_regexp WHERE REGEXP_LIKE(chardata,'B.g');
CHARDATA
------------------------------------------------------------------------------
the origin of the universe, is the Big

SYS@ocp> SELECT * FROM t_regexp WHERE REGEXP_LIKE(chardata,'B.{1}g');
CHARDATA
-------------------------------------------------------------------------------
the origin of the universe, is the Big

SYS@ocp> SELECT * FROM t_regexp WHERE REGEXP_LIKE(chardata,'B.{2}g');
CHARDATA
--------------------------------------------------------------------------------
Bang.

SYS@ocp> SELECT * FROM t_regexp WHERE REGEXP_LIKE(chardata,'[abcd]');
CHARDATA
----------------------------------------------------------------------------------------------------
A theory concerning
Bang.


@@@
@@@<4>regexp_instr(), regexp_substr()
@@@
SYS@ocp> SELECT regexp_instr(chardata,'B.{1}g')
2> FROM t_regexp
3> WHERE regexp_like(chardata,'B.{1}g');
REGEXP_INSTR(CHARDATA,'B.{1}G')
-------------------------------
                 36

SYS@ocp> SELECT regexp_instr(chardata,'B.{1}g') FROM t_regexp;
REGEXP_INSTR(CHARDATA,'B.{1}G')
-------------------------------
                  0
                 36
                  0

SYS@ocp> SELECT regexp_substr(chardata,'B.{2}g')
2> FROM t_regexp
3> WHERE regexp_like(chardata,'B.{2}g');
REGEXP_SUBSTR(CHARDATA,'B.{2}G')
--------------------------------------------------------------------------------------
Bang


@@@
@@@<5>regexp_replace()
@@@
SYS@ocp> INSERT INTO t_regexp VALUES('123-456-7890');
1 row created.

SYS@ocp> INSERT INTO t_regexp VALUES('(111)-222-3333');
1 row created.

SYS@ocp> INSERT INTO t_regexp VALUES('333-444-5555');
1 row created.

SYS@ocp> commit;
Commit complete.

SYS@ocp> ed
  1  SELECT regexp_replace(chardata,
  2               '(\()(.*)(\))-(.*)-(.*)',
  3               '\2-\4-5')
  4  AS transformed_string
  5* FROM t_regexp
SYS@ocp> /

TRANSFORMED_STRING
----------------------------------------------------------------------------------------------------
A theory concerning
the origin of the universe, is the Big
Bang.
123-456-7890
111-222-5
333-444-5555

6 rows selected.


@@@
@@@<6>continue...
@@@