Oracle PL/SQL/Regular Expressions/Escape

Материал из SQL эксперт
Перейти к: навигация, поиск

Change a dollar sign to a blank space

SQL> --Change a dollar sign to a blank space:
SQL>
SQL> SELECT REGEXP_REPLACE("$1,234.56","$"," ") FROM dual;
REGEXP_REP
----------
$1,234.56
SQL>
SQL> -- This query "failed" because what was intended was a match for a "$" rather 
than the use of the "$" as an anchor. To match the "$" in an RE, we use the escape 
character like this:
SQL>
SQL> SELECT REGEXP_REPLACE("$1,234.56","\$"," ") FROM dual;
REGEXP_RE
---------
 1,234.56
SQL>
SQL>