SQL replaces a character with a regular expression

Source: Internet
Author: User

Replace a word in a fieldTo replace a word in the memo field, for example, replace "XXX payable" with "XXX pay-as-you-go". Other words remain unchanged. The traditional update statement is very troublesome to do this update. From 10 Gb, we can use regular expressions.
SelectRegexp_replace (memo, 'Re', 'real ')FromTable_aWhereCode = '000000 ';UpdateTable_aSetMemo = regexp_replace (memo, 'response', 'real ')WhereA. Code = '20140901 '; 
Introduction to other regular functions: regexp_like: regular like
SELECT first_name, last_name
FROM employees
WHERE REGEXP_LIKE (first_name, '^Ste(v|ph)en
 
FIRST_NAME           LAST_NAME
-------------------- -------------------------
Steven               King
Steven               Markle
Stephen              Stiles
Regexp_instr: determines the number of BITs that meet the regular expression condition: '100 Oracle Parkway, Redwood Shores, CA 'source string' [S | r | p] [[: Alpha:] {6} 'regular expression, starting with S | r | P and starting with 6 letters and 3. The default value is 12. Oracle search meets 2nd modes, the default value is 11 and the string following the matching mode is returned. The default value is 0 I, which is case insensitive.
SELECT
 REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA',
               '[s|r|p][[:alpha:]]{6}', 3, 2, 1, 'i') "REGEXP_INSTR"
 FROM DUAL;
 
REGEXP_INSTR
------------
          28
Regexp_substr
SELECT
 REGEXP_SUBSTR('http://www.oracle.com/products',
                'http://([[:alnum:]]+/.?){3,4}/?') "REGEXP_SUBSTR"
 FROM DUAL;
 
REGEXP_SUBSTR
----------------------
http://www.oracle.com/
 
Wonder

2008-03-20
);

___FCKpd___3
___FCKpd___4
___FCKpd___5
___FCKpd___6
___FCKpd___7
___FCKpd___8
Regexp_instr: determines the number of BITs that meet the regular expression condition: '100 Oracle Parkway, Redwood Shores, CA 'source string' [S | r | p] [[: Alpha:] {6} 'regular expression, starting with S | r | P and starting with 6 letters and 3. The default value is 12. Oracle search meets 2nd modes, the default value is 11 and the string following the matching mode is returned. The default value is 0 I, which is case insensitive.
___FCKpd___9
___FCKpd___10
___FCKpd___11
___FCKpd___12
___FCKpd___13
___FCKpd___14
___FCKpd___15
___FCKpd___16
Regexp_substr
___FCKpd___17
___FCKpd___18
___FCKpd___19
___FCKpd___20
___FCKpd___21
___FCKpd___22
___FCKpd___23
___FCKpd___24
 
Wonder

2008-03-20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.