Home Database Mysql Tutorial Oracle正则表达式函数详解

Oracle正则表达式函数详解

Jun 07, 2016 pm 05:32 PM
oracle function

Oracle 10g提供了四个正则表达式函数regexp function: REGEXP_LIKE, REGEXP_REPLACE,REGEXP_INSTR,REGEXP_SUBSTR。

Oracle 10g提供了四个正则表达式函数regexp function: REGEXP_LIKE, REGEXP_REPLACE,REGEXP_INSTR,REGEXP_SUBSTR。


REGEXP_LIKE:(匹配) 比较一个字符串是否与正则表达式匹配
(srcstr, pattern [, match_option])

REGEXP_INSTR:(包含)在字符串中查找正则表达式,并且返回匹配的位置
(srcstr, pattern [, position [, occurrence [, return_option [, match_option]]]])

REGEXP_SUBSTR:(提取) 返回与正则表达式匹配的子字符串
(srcstr, pattern [, position [, occurrence [, match_option]]])
REGEXP_REPLACE:(替换)搜索并且替换匹配的正则表达式
(srcstr, pattern [, replacestr [, position [, occurrence [, match_option]]]])

srcstr: 被查找的字符数据。
pattern: 正则表达式。
occurrence: 出现的次数。默认为1。
position: 开始位置
return_option: 默认值为0,返回该模式的起始位置;值为1则返回符合匹配条件的下一个字符的起始位置。
replacestr: 用来替换匹配模式的字符串。
match_option: 匹配方式选项。缺省为c。
c:case sensitive
I:case insensitive
n:(.)匹配任何字符(包括newline)
m:字符串存在换行的时候被作为多行处理

##################################################################################

正则表达式由以下标准的元字符(metacharacters)所构成: 字符

[[:alpha:]]任何字母。[A-Za-z]

[[:digit:]]任何数字。[0-9]
[[:alnum:]]任何字母和数字。[A-Za-z0-9]
[:blank:] [ ],标准是空格和TAB,但Oracle里只有空格!
[:cntrl:] CONTROL键
[:graph:] 即所有可见字符,不包括空格
[:print:] 可打印字符 ,即空格+所有可见字符
[[:space:]] 空白字符。
[[:punct:]] 任何标点符号。
[[:upper:]] 任何大写字母。[A-Z]
[[:lower:]] 任何小写字母。[a-z]
[[:xdigit:]]任何16进制的数字,相当于[0-9a-fA-F]。
#######
[:class:] 字符类。class如alnum、digit等。
[.element.] 整理类。受NLS_SORT影响。将多字节字符当作单字节字符看待。如在西班牙语中ch、ll都是用多字节表示的单字节。
[=char=] 等同类。在当前语言(Locale)下,匹配所有的属于相同的POSIX等同类字符指定的字符。如在西班牙语中,,[[=n=]]指定了等同类字符n,它可以匹配El Ni?o中的N和 ?.
###########################################################################

边界符集合

^ 每一行的开头,单行模式下等价于字符串的开头
$ 每一行的结尾,单行模式下等价于字符串的结尾
在单行模式下,^和\A等价,$和\Z等价。
##########################################################################

重复次数集合

* 匹配零次或多次--尽可能多的次数
? 零次或一次
+ 一次或多次
{m} {m}?正好m次,贪婪与非贪婪一样的
{m,} {m,}?至少m次
{m, n} {m, n}?最少m最多n次
在上述字符后加?,如:*?,即为非贪婪模式。
贪婪模式会获取尽可能多的字符,而非贪婪模式会获取尽可能少的字符
###############################################################

更多详情见请继续阅读下一页的精彩内容

推荐阅读:

精通正则表达式(第3版) PDF高清中文版

Oracle函数之Replace() 

Oracle函数大全

Oracle函数之case和decode的用法区别及性能比较

Oracle函数和存储过程简单实例

linux

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

How do you create indexes on JSON columns? How do you create indexes on JSON columns? Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

How do you represent relationships using foreign keys? How do you represent relationships using foreign keys? Mar 19, 2025 pm 03:48 PM

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? Mar 18, 2025 pm 12:00 PM

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)

See all articles