Home > Database > Oracle > body text

Usage of regexp_like in oracle

下次还敢
Release: 2024-05-03 00:09:33
Original
405 people have browsed it

The REGEXP_LIKE function in Oracle is used to compare whether a string matches a regular expression and returns a Boolean value: Syntax: REGEXP_LIKE(string, regexp, [condition]) Parameters: string, regular expression pattern, Optional matching conditions (default: simple comparison) Usage: Specify strings and regular expression patterns, such as REGEXP_LIKE('string', 'pattern') Examples: Match starts with "ABC", contains "XYZ" or is size-insensitive Write a string matching "PATTERN"

Usage of regexp_like in oracle

Usage of REGEXP_LIKE in Oracle

REGEXP_LIKE Function Overview

The REGEXP_LIKE function is used to compare whether a string matches a given regular expression. It returns a Boolean value indicating the result of the comparison.

Syntax

<code>REGEXP_LIKE(string, regexp, [condition])</code>
Copy after login

Parameters

  • string: The string to be compared.
  • regexp: Regular expression pattern.
  • condition (optional): Specifies the condition for pattern matching. The default value is 0.

condition parameter

condition parameter can specify the condition for pattern matching:

  • 0: Default , indicating a simple comparison.
  • 1: means not case sensitive.
  • 2: indicates multi-byte character matching.

Usage

To use the REGEXP_LIKE function, specify the string to compare and the regular expression pattern as follows:

<code>REGEXP_LIKE('my_string', 'pattern')</code>
Copy after login

Example

Regular expression example

  • ^pattern$: Matches those that begin and end with pattern String.
  • .*pattern: Matches a string containing pattern anywhere.
  • [abc]: Match any one of the characters a, b or c.

Example 1: Check if the string starts with "ABC"

<code class="sql">SELECT REGEXP_LIKE('ABCDE', 'ABC') FROM DUAL;</code>
Copy after login

Result: 1 (true)

Example 2: Check if the string contains "XYZ"

<code class="sql">SELECT REGEXP_LIKE('DEFXYZGHI', '.*XYZ.*') FROM DUAL;</code>
Copy after login

Result: 1 (True)

Example 3: Case-insensitive match string

<code class="sql">SELECT REGEXP_LIKE('my_string', 'PATTERN', 1) FROM DUAL;</code>
Copy after login

Result: 1 (True)

The above is the detailed content of Usage of regexp_like in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!