加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

[每日一题] OCP1z0-047 :2013-08-22 ? 正则表达式---[^Ale|ax.r$

发布时间:2020-12-14 02:17:19 所属栏目:百科 来源:网络整理
导读:转载请注明出处:http://www.jb51.cc/article/p-kvyfcwnh-dk.html 650) this.width=650;" alt="" src="http://img.jb51.cc/vcimg/static/loading.png" src="http://img.blog.csdn.net/20130822235005390"> 正确答案:DE 一、Oracle正则表达式的相关知识点 '

转载请注明出处:http://www.52php.cn/article/p-kvyfcwnh-dk.html

正确答案:DE

一、Oracle正则表达式的相关知识点

'[^Ale|ax.r$]':

^:匹配行的开始字符

$:匹配行的结束字符

[]:方括号表示指定一个匹配列表,该列表匹配列表中显示的任何表达式。

[^]:同上面相反,非匹配列表表达工。

.:匹配任意一个字符(除了NULL)

|:替换元字符;结束第一个选项并开始下一个替换表达式

[^Ale|ax.r$]'中^表示只匹配不在集合{'A','l','e','|','a','x','.','r','$'}中的字符,此处的'|'、'.'、'$'只是表示普通的字符,而非匹配符。字符串: [Ale|ax.r$] 匹配Alex,Alax ,Alxer ,A,l,e,a.............

不包含 A l e a x r的串,等效于[^Aleaxr],只要在串里面找到符合条件的字符(哪怕就一个)就算匹配。

先来看一下答案:

gyj@MYDB> with gyj_test as (   2   select 'Alex' name from dual   3   union all   4   select 'Alax' name from dual   5   union all   6   select 'Alxer' name from dual   7   union all   8   select 'Alexender' name from dual   9   union all  10   select 'Alexendar' name from dual)  11   select * from gyj_test where  regexp_like(name,'[^Ale|ax.r$]');  NAME --------- Alexender Alexendar 


二、分析:

'^Ale|ax.r$'??表示匹配Ale或ax开头的字符串,.表示任一字符。

gyj@MYDB> create table gyj_test1 (id int,name varchar2(20));  Table created.  gyj@MYDB> insert into gyj_test1 values(1,'Alex');  1 row created.  gyj@MYDB> insert into gyj_test1 values(2,'Alax');  1 row created.  gyj@MYDB> insert into gyj_test1 values(3,'Alxer');  1 row created.  gyj@MYDB> insert into gyj_test1 values(4,'Alexender');  1 row created.  gyj@MYDB> insert into gyj_test1 values(4,'Alexendar');  1 row created.  gyj@MYDB> commit;  Commit complete.


gyj@MYDB> select * from gyj_test1 where regexp_like(name,'^Ale|ax.r$');          ID NAME ---------- --------------------          1 Alex          4 Alexender          4 Alexendar


三、以上的SQL语句等价于:

gyj@MYDB> select * from gyj_test1 where  regexp_like(name,'^Ale')   2   union all   3   select * from gyj_test1 where  regexp_like(name,'ax.r$');          ID NAME ---------- --------------------          1 Alex          4 Alexender          4 Alexendar 


四、^出现在[]中表示否定,查询的结果集里含有不是中括号里的字母Aleaxr

gyj@MYDB> select * from gyj_test1 where  regexp_like(name,'[^Ale|ax.r$]');          ID NAME ---------- --------------------          4 Alexender          4 Alexendar 


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

ITPUB:http://www.itpub.net/space-uid-28460966.html

OCM: http://education.oracle.com/education/otn/YGuo.HTM

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读