PLSQL_regexp

探查模式:

declare
   names varchar2(60):='zhangxuegang,zhangsan,lisi,wangwu,zhaoliu';
   names_adjusted varchar2(61);
   comma_delimited boolean;
 begin
 --查询是否包括某种模式
 comma_delimited:=regexp_like(names,'^([a-z A-Z]*,)+([a-z A-Z]*){1}$');
 --显示查找结果
  dbms_output.put_line(
  case comma_delimited
  when true then 'we have a delimited list!'
  else 'the pattern does not match .'
  end );
  end;

 不难看出regexp_like与like的功能类似。

 

定位模式

SELECT REGEXP_INSTR('Joe Smith, 10045 Berry Lane, San Joseph, CA 91234',
                    '[[:digit:]]{5}$') AS rx_instr
  FROM DUAL; 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2012-09-06 16:40  Mr-sniper  阅读(274)  评论(0编辑  收藏  举报