How to use regexp_instr function in mysql
This article mainly explains "the use of regexp_instr function in mysql". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the use of regexp_instr function in mysql".
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 | +-+ Thank you for your reading The above is the content of "the use of regexp_instr function in mysql". After the study of this article, I believe you have a deeper understanding of the use of regexp_instr function in mysql, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!