Home  >  Article  >  Database  >  Oracle基础教程:单行函数—正则表达式函数

Oracle基础教程:单行函数—正则表达式函数

WBOY
WBOYOriginal
2016-06-07 17:11:41860browse

正则表达式函数 (10g引入) regexp_like(

正则表达式函数 (10g引入)
regexp_like('S','RE','O')
 S 被搜索的字符串或者列表达式
 RE 正则内容
 O 参数(可选)
idle> select ename from emp where regexp_like(ename,'S');

ENAME
----------
SMITH
JONES
SCOTT
ADAMS
JAMES

idle> select ename from emp where regexp_like(ename,'^S.*T');

ENAME
----------
SMITH
SCOTT

idle>

idle> select ename from emp where regexp_like(ename,'^s.*T$','i');忽略大小写

ENAME
----------
SCOTT

idle>


regexp_replace(S,'RE','NEW')
idle> select ename,regexp_replace(ename,'S..T','=') aaa from emp where regexp_like (ename,'S..T');

ENAME    AAA
---------- ----------
SMITH    =H
SCOTT    =T

idle>

regexp_replace(S,'RE','NEW')
idle> select ename,regexp_replace(ename,'S.*T','=') aaa from emp where regexp_like (ename,'S.*T');

ENAME    AAA
---------- ----------
SMITH    =H
SCOTT    =

idle>

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn