附件
![fj.png](/image/default/fj.png)
前言
instr函数基本可以实现常规的一些功能需求,通过强化的正则达式化的regexp_instr可以达到一些高级自定义化的功能
测试结论
1,regexp_instr有7个参数
2,有些参数可以不提供参数值,数据库会自动提供一个默认值
测试明细
1,如果未找到匹配字符串,返回0,如何匹配字符串,依赖于参数 return_opt
2,regexp_instr各个参数含义:
2.1,source_char,它是用于查找的源字符串,通常它是一个字符列,可以是
CHAR,VARCHAR2,NCHAR,NVARCHAR2,CLOB,NCLOB类型的任何数据
2.2,pattern,正则表达式,通常是一个文本常量,类型为CHAR,VARCHAR2,NCHAR,NVARCHAR2
它最多可以包含512字节;
如果PATTERN数据类型不同于SOURCE_CHAR,数据库会自动把它转换为与SOURCE_CHAR一致
PATTERN包含的可以支持的正则表达式
完整及权威的正则表达式相关信息,请参考:ORACLE DATABASE ADVANCED APPLICATION DEVELOPERS’S GUIDE.
(为了完整起见,我会列举中英语对译,便于我及大家参考,如果你英语好直接看英语即可^^)
Operator | Description |
---|---|
\ |
The backslash character can have four different meanings depending on the context. It can:
这是一个反斜杠字符,在不同的场景中有4种不同的含义:
|
* | Matches zero or more occurrences 匹配0或多个发生的事件(事件即匹配的行为) |
+ |
Matches one or more occurrences 匹配1或多个发生的事件
|
? | Matches zero or one occurrence 匹配0或1个发生的事件 |
| |
Alternation operator for specifying alternative matches
指定多个可以替代或可选的的匹配的发生事件(即就是或的关系,或为OR)
|
^ |
Matches the beginning of a string by default. In multiline mode, it matches the beginning of any line anywhere within the source string.
默认从一个字符开始进行匹配查找,如果处于多行模式,它会从源字符串的任何行开头进行匹配
|
$ |
Matches the end of a string by default. In multiline mode, it matches the end of any line anywhere within the source string.
与^正好相反,它是从一个字符的结束开始查找,在多行模式下,同上相反
|
. |
Matches any character in the supported character set except NULL
除了NULL外,匹配查找任何可以被支持的字符集的字符
|
[ ] |
Bracket expression for specifying a matching list that should match any one of the expressions represented in the list. A non-matching list expression begins with a circumflex (^) and specifies a list that matches any character except for the expressions represented in the list.
括号表达式,它会指定一个匹配的列表,即会匹配查找这个列表中的任何一个表达式(也就是说会在括号中包括一众表达式,只要匹配其中一个表达式即可)
非匹配列表表达式,即以^开头,即匹配时,不能匹配这些指定的表达式
To specify a right bracket (]) in the bracket expression, place it first in the list (after the initial circumflex (^), if any).
为了在括号表达式中指定一个右括号,会把它放在列表的开头(注意如果存在^,是在最开始的^之后哟)
To specify a hyphen in the bracket expression, place it first in the list (after the initial circumflex (^), if any), last in the list, or as an ending range point in a range expression.
如果想在括号表达式中指定一个连字符,把它放在列表的开头(注意如果存在^,是在最开始的^之后哟),列表的结束,或者在一个范围表达式中作为结束的范围结束点
|
( ) |
Grouping expression, treated as a single subexpression
分组表达式,会被视为一个单一的子表达式
|
{m} |
Matches exactly m times
精确匹配多次(多次由M指定)
|
{m,} |
Matches at least m times
至少匹配多次
|
{m,n} |
Matches at least m times but no more than n times
至少匹配M次,但至多N次
|
\n |
The backreference expression (n is a digit between 1 and 9) matches the nth subexpression enclosed between '(' and ')' preceding the \n
反向引用表达式(N表示1至9的中任何一个数字),去匹配在( )之间的第N个子表达式,一直到换行符结束
|
[..] |
Specifies one collation element, and can be a multicharacter element (for example, [.ch.] in Spanish)
指定1个核对或验证的元素,可能是一个多字符元素哟(如:西班牙语中的[.ch.])
|
[: :] |
Specifies character classes (for example, [:alpha:]). It matches any character within the character class.
指定字符类型(如:[:alpha:]),它会去匹配这个字符类型中的任何字符(类似于模糊匹配一样)
|
[==] |
Specifies equivalence classes. For example, [=a=] matches all characters having base letter 'a'.
指定等值类型,如: [=a=],会去匹配具有基字符A的所有字串
|
个人简介
项目经验:
贵州移动crm及客服数据库性能优化项目
贵州移动crm及客服务数据库sql审核项目
深圳穆迪软件有限公司数据库性能优化项目
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-1700367/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-1700367/