OCP-047 REGEXP_INSTR()

91. View the Exhibit and examine the data in the LOCATIONS table.
Evaluate the following SQL statement:
SELECT street_address
FROM locations WHERE REGEXP_INSTR(street_address,'[^[:alpha:]]') = 1;----- -查询street_address已数字开头的地址信息而非字母开头

Which statement is true regarding the output of this SQL statement?


A. It would display all the street addresses that do not have a substring
'alpha'.
B. It would display all the street addresses where the first character is
a special character.
C. It would display all the street addresses where the first character is
a letter of the alphabet.
D. It would display all the street addresses where the first character is
not a letter of the alphabet.

Answer: D


解题说明:

[....]: 匹配字符list

[^ ... ]:不匹配字符list

[:class:]:字符类

常用的标准字符类如下:

alnum    字母和数字

alpha     字母

blank     空白,包括空格、制表符等

digit      数字

lower     小写字母

space   空白,包括空格、制表符、竖向制表符、换行、回车,注意与 blank 类的区别

upper    大写字母

xdigit    十六进制数字字符

举例:






REGEXP_INSTR

Syntax

Description of regexp_instr.gif follows
Description of the illustration regexp_instr.gif

Purpose

REGEXP_INSTR extends the functionality of the INSTR function by letting you search a string for a regular expression pattern. The function evaluates strings using characters as defined by the input character set. It returns an integer indicating the beginning or ending position of the matched substring, depending on the value of the return_option argument. If no match is found, the function returns 0.

This function complies with the POSIX regular expression standard and the Unicode Regular Expression Guidelines. For more information, please refer toAppendix C, "Oracle Regular Expression Support".

  • source_char is a character expression that serves as the search value. It is commonly a character column and can be of any of the datatypes CHAR,VARCHAR2NCHARNVARCHAR2CLOB, or NCLOB.

  • pattern is the regular expression. It is usually a text literal and can be of any of the datatypes CHARVARCHAR2NCHAR, or NVARCHAR2. It can contain up to 512 bytes. If the datatype of pattern is different from the datatype of source_char, Oracle Database converts pattern to the datatype of source_char. For a listing of the operators you can specify in pattern, please refer to Appendix C, "Oracle Regular Expression Support".

  • position is a positive integer indicating the character of source_char where Oracle should begin the search. The default is 1, meaning that Oracle begins the search at the first character of source_char.

  • occurrence is a positive integer indicating which occurrence of pattern in source_char Oracle should search for. The default is 1, meaning that Oracle searches for the first occurrence of pattern.

  • return_option lets you specify what Oracle should return in relation to the occurrence:

    • If you specify 0, then Oracle returns the position of the first character of the occurrence. This is the default.

    • If you specify 1, then Oracle returns the position of the character following the occurrence.

  • match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:

    • 'i' specifies case-insensitive matching.

    • 'c' specifies case-sensitive matching.

    • 'n' allows the period (.), which is the match-any-character character, to match the newline character. If you omit this parameter, the period does not match the newline character.

    • 'm' treats the source string as multiple lines. Oracle interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, Oracle treats the source string as a single line.

    • 'x' ignores whitespace characters. By default, whitespace characters match themselves.

    If you specify multiple contradictory values, Oracle uses the last value. For example, if you specify 'ic', then Oracle uses case-sensitive matching. If you specify a character other than those shown above, then Oracle returns an error.

    If you omit match_parameter, then:

    • The default case sensitivity is determined by the value of the NLS_SORT parameter.

    • A period (.) does not match the newline character.

    • The source string is treated as a single line.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值