转载请注明出处:http://www.jb51.cc/article/p-vslmamwp-dk.html
正确答案:D
根据题意WHERE条件的意思是“street_address”列中第一个位置不为字符(即为数字),执行以上sql语句,如下结果:
hr@MYDB> SELECT street_address 2 FROM locations 3 WHERE 4 REGEXP_INSTR(street_address,'[^[:alpha:]]')=1; STREET_ADDRESS ---------------------------------------- 1297 Via Cola di Rie 93091 Calle della Testa 2017 Shinjuku-ku 9450 Kamiya-cho 2014 Jabberwocky Rd 2011 Interiors Blvd 2007 Zagora St 2004 Charade Rd 147 Spadina Ave 6092 Boxwood St 40-5-12 Laogianggen 1298 Vileparle (E) 12-98 Victoria Street 198 Clementi North 8204 Arthur St 9702 Chester Road 20 Rue des Corps-Saints 17 rows selected.
REGEXP_INSTR函数
语法 |
说明 |
REGEXP_INSTR(source_string,pattern |
该函数查找pattern,并返回该模式的第一个位置。您可以随意指定您想要开始搜索的 start_position。 occurrence 参数默认为 1,除非您指定您要查找接下来出现的一个模式。return_option 的默认值为 0,它返回该模式的起始位置;值为 1 则返回符合匹配条件的下一个字符的起始位置。 |
'^'匹配输入字符串的开始位置,在方括号表达式中使用,此时它表示不接受该字符集合。
[[:alpha:]]任何字母。
[^[:alpha:]]非任何字母
如下操作:
gyj@MYDB> select REGEXP_INSTR('guoyJoe','[^[:alpha:]]') from dual; REGEXP_INSTR('GUOYJOE','[^[:ALPHA:]]') -------------------------------------- 0 gyj@MYDB> select REGEXP_INSTR('1guoyJoe','[^[:alpha:]]') from dual; REGEXP_INSTR('1GUOYJOE','[^[:ALPHA:]]') ---------------------------------------
参考官方文档:
The following example examines the string,looking for occurrences of one or more non-blank characters. Oracle begins searching at the first character in the string and returns the starting position (default) of the sixth occurrence of one or more non-blank characters.
gyj@MYDB> SELECT 2 REGEXP_INSTR('500 Oracle Parkway,Redwood Shores,CA',3 '[^ ]+',1,6) "REGEXP_INSTR" 4 FROM DUAL; REGEXP_INSTR ------------ 37
The following example examines the string,looking for occurrences of words beginning with
s
,r
,or
p
,regardless of case,followed by any six alphabetic characters. Oracle begins searching at the third character in the string and returns the position in the string of the character following the second occurrence of a seven-letter word beginning with
s
,regardless of case.
gyj@MYDB> SELECT 2 REGEXP_INSTR('500 Oracle Parkway,3 '[s|r|p][[:alpha:]]{6}',3,2,'i') "REGEXP_INSTR" 4 FROM DUAL; REGEXP_INSTR ------------ 28
QQ:252803295
学习交流QQ群:
DSI&Core Search Ⅰ 群:127149411(技术:已满)
DSI&Core Search Ⅱ 群:177089463(技术:未满)
DSI&Core Search Ⅲ 群:284596437(技术:未满)
DSI&Core Search Ⅳ 群:192136702(技术:未满)
DSI&Core Search Ⅴ 群:285030382(闲聊:未满)
MAIL:oracledba_cn@hotmail.com
BLOG:http://blog.csdn.net/guoyjoe
WEIBO:http://weibo.com/guoyJoe0218
原文链接:https://www.f2er.com/regex/362648.html