Home  >  Article  >  Database  >  Oracle正则表达式简单例子

Oracle正则表达式简单例子

WBOY
WBOYOriginal
2016-06-07 16:55:551250browse

1. 非贪婪模式 ? 当该字符紧跟在任何一个其他限制符(*,+,?,{n},{n,},{n,m})后面时,匹配模式是非贪婪的。非贪婪模式

  1. 非贪婪模式

  ? 当该字符紧跟在任何一个其他限制符(*,+,?,{n},{n,},{n,m})后面时,匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串,而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如,对于字符串“oooo”,“o+?”将匹配单个“o”,,而“o+”将匹配所有“o”。

  2.

  (?:pattern) 匹配pattern但不获取匹配结果,也就是说这是一个非获取匹配,不进行存储供以后使用。这在使用或字符“(|)”来组合一个模式的各个部分是很有用。例如“industr(?:y|ies)”就是一个比“industry|industries”更简略的表达式。

  (?=pattern) 正向预查,在任何匹配pattern的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如,“Windows(?=95|98|NT|2000)”能匹配“Windows2000”中的“Windows”,但不能匹配“Windows3.1”中的“Windows”。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始。

  (?!pattern) 负向预查,在任何不匹配pattern的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如“Windows(?!95|98|NT|2000)”能匹配“Windows3.1”中的“Windows”,但不能匹配“Windows2000”中的“Windows”。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始

  3.

  \b 匹配一个单词边界,也就是指单词和空格间的位置。例如,“er\b”可以匹配“never”中的“er”,但不能匹配“verb”中的“er”。

  \B 匹配非单词边界。“er\B”能匹配“verb”中的“er”,但不能匹配“never”中的“er”。

  4. Oracle11g正则表达式

  

Match Options

Character Class Description

c Case sensitive matching

i Case insensitive matching

m Treat source string as multi-line activating Anchor chars

n Allow the period (.) to match any newline character


Posix Characters

Character Class Description

[:alnum:] Alphanumeric characters

[:alpha:] Alphabetic characters

[:blank:] Blank Space Characters

[:cntrl:] Control characters (nonprinting)

[:digit:] Numeric digits

[:graph:] Any [:punct:], [:upper:], [:lower:], and [:digit:] chars

[:lower:] Lowercase alphabetic characters

[:print:] Printable charactersa

[:punct:] Punctuation characters

[:space:] Space characters (nonprinting), such as carriage return, newline, vertical tab, and form feed

[:upper:] Uppercase alphabetic characters

[:xdigit:] Hexidecimal characters

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