Home Database Mysql Tutorial Oracle 正则表达式

Oracle 正则表达式

Jun 07, 2016 pm 04:57 PM
oracle database

REGEXP_INSTR(source_string, pattern[, start_position[, occurrence[, return_option[, match_parameter]]]])函数(10g新函数)描

分组字符

定义

举例

()

此字符可以组合括号内模式所匹配的字符,它是一个捕获组,也就是说模式匹配的字符作为最终设置了ExplicitCapture选项――默认状态下字符不是匹配的一部分

输入字符串为:ABC1DEF2XY

匹配3个从A到Z的字符和1个数字的正则表达式:([A-Z]{3}\d)

将产生两次匹配:Match 1=ABC1;Match 2=DEF2

每次匹配对应一个组:Match1的第一个组=ABC;Match2的第1个组=DEF

有了反向引用,就可以通过它在正则表达式中的编号以及C#和类Group,GroupCollection来访问组。如果设置了ExplicitCapture选项,,就不能使用组所捕获的内容

(?:)

此字符可以组合括号内模式所匹配的字符,它是一个非捕获组,这意味着模式所的字符将不作为一个组来捕获,但它构成了最终匹配结果的一部分。它基本上与上面的组类型相同,但设定了选项ExplicitCapture

输入字符串为:1A BB SA1 C

匹配一个数字或一个A到Z的字母,接着是任意单词字符的正则表达式为:(?:\d|[A-Z]\w)

它将产生3次匹配:每1次匹配=1A;每2次匹配=BB;每3次匹配=SA

但是没有组被捕获

(?

此选项组合括号内模式所匹配的字符,并用尖括号中指定的值为组命名。在正则表达式中,可以使用名称进行反向引用,而不必使用编号。即使不设置ExplicitCapture选项,它也是一个捕获组。这意味着反向引用可以利用组内匹配的字符,或者通过Group类访问

输入字符串为:Characters in Sienfeld included Jerry Seinfeld,Elaine Benes,Cosno Kramer and George Costanza能够匹配它们的姓名,并在一个组llastName中捕获姓的正则表达式为:\b[A-Z][a-z]+ (?[A-Z][a-z]+)\b

它产生了4次匹配:First Match=Jerry Seinfeld; Second Match=Elaine Benes; Third Match=Cosmo Kramer; Fourth Match=George Costanza

每一次匹配都对应了一个lastName组:

第1次匹配:lastName group=Seinfeld

第2次匹配:lastName group=Benes

第3次匹配:lastName group=Kramer

第4次匹配:lastName group=Costanza

不管是否设置了选项ExplictCapture,组都将被捕获

(?=)

正声明。声明的右侧必须是括号中指定的模式。此模式不构成最终匹配的一部分

正则表达式\S+(?=.NET)要匹配的输入字符串为:The languages were Java,C#.NET,VB.NET,C,Jscript.NET,Pascal

将产生如下匹配:〕

C#

VB

JScript.

(?!)

负声明。它规定模式不能紧临着声明的右侧。此模式不构成最终匹配的一部分

\d{3}(?![A-Z])要匹配的输入字符串为:123A 456 789111C

将产生如下匹配:

456

789

(?

反向正声明。声明的左侧必须为括号内的指定模式。此模不构成最终匹配的一部分

正则表达式(?

它将产生如下匹配:

Mexico

England

(?

反向正声明。声明的左侧必须不能是括号内的指定模式。此模式不构成最终匹配的一部分

正则表达式(?

它将实现如下匹配:

56F

89C

(?>)

非回溯组。防止Regex引擎回溯并且防止实现一次匹配

假设要匹配所有以“ing”结尾的单词。输入字符串如下:He was very trusing

正则表达式为:.*ing

它将实现一次匹配――单词trusting。“.”匹配任意字符,当然也匹配“ing”。所以,Regex引擎回溯一位并在第2个“t”停止,然后匹配指定的模式“ing”。但是,如果禁用回溯操作:(?>.*)ing

它将实现0次匹配。“.”能匹配所有的字符,包括“ing”――不能匹配,从而匹配失败

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

What to do if the oracle can't be opened What to do if the oracle can't be opened Apr 11, 2025 pm 10:06 PM

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

What to do if the oracle log is full What to do if the oracle log is full Apr 12, 2025 am 06:09 AM

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

See all articles