[每日一题] OCP1z0-047 :2013-08-21 ? 正则表达式---REGEXP_INST
转载请注明出处:http://www.52php.cn/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函数
'^'匹配输入字符串的开始位置,在方括号表达式中使用,此时它表示不接受该字符集合。 [[: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:]]') --------------------------------------- 参考官方文档:
Examples 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群: MAIL:oracledba_cn@hotmail.com BLOG:http://blog.csdn.net/guoyjoe WEIBO:http://weibo.com/guoyJoe0218 ITPUB:http://www.itpub.net/space-uid-28460966.html OCM: http://education.oracle.com/education/otn/YGuo.HTM (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |