ocp1z0-047: Regular Expression---regexp_replace function

Source: Internet
Author: User

This problem is also the expression of Kauzheng, we first according to the question, the operation is as follows:

hr@ocm> col "PHONE number" for A50  
hr@ocm> SELECT phone_number,regexp_replace (Phone_number, ' ([[:d igit:]]{3} )\. ([[:d igit:]]{3}] \. ([[:d igit:]]{4}] ', ' (\1) \2-\3 ') "PHONE number"
  2 from  employees;  
      
Phone_number         PHONE number  
----------------------------------------------------------------------  
650.507.9833         (650) 507-9833  
650.507.9844         (650) 507-9844  
515.123.4444         (515) # 123-4444  
011.44.1644.429264   011.44.1644.429264  
011.44.1644.429263   011.44.1644.429263  
011.44.1644.429262   011.44.1644.429262  
omit results ...  
650.501.4876         (650) 501-4876  
650.507.9811         (650) 507-9811  
650.507.9822         (650) 507-9822-  
      
rows selected.

According to the query results can be the correct answer is: C
*************************************************************

Regexp_replace function

Let's first look at the traditional replace SQL function, which replaces a string with another string. Suppose your data has unnecessary spaces in the body, and you want to replace them with a single space. With the Replace function, you need to accurately list how many spaces you want to replace. However, the number of extra spaces may not be the same throughout the body. The following example has three spaces between Joe and Smith. The parameters of the Replace function specify that you want to replace two spaces with a single space. In this case, the result leaves an extra space between Joe and Smith in the original string.

SELECT REPLACE (' Joe Smith ', ', ') as  
replace from  
dual  
replace  
---------  
Joe Smith

The Regexp_replace function advances the substitution function a step further, and its syntax is listed in Table 9. The following query replaces any two or more spaces with a single space. () A subexpression contains a single space that can be repeated two or more times as instructed by {2.}

SELECT regexp_replace (' Joe Smith ',  
' () {2,} ', ') as  
rx_replace from  
dual  
rx_replace  
--------- -  
Joe Smith

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.