Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RLIKE operator determines string matching regular expression handout

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following content mainly brings you RLIKE operator to determine string matching regular expression handout, the knowledge here is slightly different from books, are professional and technical personnel in the process of contact with users, summed up, has a certain experience sharing value, hope to bring help to the majority of readers.

In MySQL, the RLIKE operator is used to determine whether a string matches a regular expression. It is synonymous with REGEXP_LIKE ().

If the string matches the provided regular expression, the result is 1, otherwise 0.

The syntax goes like this:

Expr RLIKE pat

Where expr is the input string and pat is the regular expression of the test string.

Examples

Here is an example of how to use this operator in a SELECT statement:

SELECT 'Tweet' REGEXP' ^ Tw.*t$'

Results:

+-- + | 'Tweet' REGEXP' ^ Tw.*t$' | +-+ | 1 | +-+

In this case, the return value of 1 indicates that the input string matches the regular expression. In particular, we specify that the input string should start with Tw and end with t (this is because we started the mode ^ Tw and ended with t $). It's time. Section specifies any character and * specifies that it can be zero for any number of (any) characters. So. * means that there can be no characters, one character or many characters between the beginning and the end.

Here's what happens if we get rid of *:

SELECT 'Tweet' REGEXP' ^ Tw.t$'

Results:

+-+ | 'Tweet' REGEXP' ^ Tw.t$' | +-+ | 0 | +-+

Returning a result of 0 means a mismatch. This is because. Specify only one instance of any character. Our input string contains two instances

SELECT 'Twet' REGEXP' ^ Tw.t$' AS 'Twet',' Twit' REGEXP'^ Tw.t$' AS 'Twit',' Twt' REGEXP'^ Tw.t$' AS 'Twt',' Tw.t' REGEXP'^ Tw.t$' AS 'Tw.t'

Results:

+-+ | Twet | Twit | Twt | Tw.t | +-+ | 1 | 1 | 0 | 1 | +-+

Correlation

These are the details of the use of the RLIKE operator in MySQL. Please pay more attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report