Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the regexp_instr function in mysql

Shulou Source: shulou.com Published: 2022-05-31 10:54:50 09月22日 Update

Today, I would like to share with you the relevant knowledge points about how to use the regexp_instr function in mysql. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

1. The function returns the substring position of the matching pattern pat in the string expr. If no matching substring is found, 0 is returned.

2. If expr or pat is NULL, the function returns NULL. The position of the character starts at 1.

Optional parameters:

Pos means to start the search at the specified location of the string expr. By default, the match starts with the first character.

Occurrence indicates the number of matches returned. By default, the substring position of the first match is returned.

Return_option represents the type of location returned. If the parameter is 0 (the default), the position of the first character of the substring is returned; if the parameter is 1, the position of the first character after the substring is returned.

Match_type represents the way it matches, and the parameters are the same as the REGEXP_LIKE () function above.

Example

Mysql > SELECT REGEXP_INSTR ('dog cat dog',' dog') +-- + | REGEXP_INSTR ('dog cat dog' 'dog') | +-+ | 1 | +-+ mysql > SELECT REGEXP_INSTR (' dog cat dog', 'dog', 2) +-- + | REGEXP_INSTR ('dog cat dog',' dog' 2) | +-- + | 9 | +-- + mysql > SELECT REGEXP_INSTR ('aa aaa aaaa', 'a {2}') +-- + | REGEXP_INSTR ('aa aaa aaaa' 'a {2}') | +-- + | 1 | +-+ mysql > SELECT REGEXP_INSTR ('aa aaa aaaa', 'a {4}') +-- + | REGEXP_INSTR ('aa aaa aaaa' 'a {4}') | +-+ | 8 | +-+ above is all the content of the article "how to use regexp_instr functions in mysql" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Position character function parameter knowledge article content string face different large consistent most examples namely way more pattern knowledge point type Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB vpn Apple Shulou Technology