简体   繁体   English

如何使用“ REGEXP”运算符实现“ LIKE'%a%a%'”

[英]How to achieve “LIKE '%a%a%'” with 'REGEXP' operator

Consider the following line to search for strings using the LIKE operator: 考虑以下行以使用LIKE运算符搜索字符串:

LIKE '%a%a%'

This returns when the selected string has two or more instances of the letter 'a' in the string. 当所选字符串在字符串中具有两个或多个字母“ a”的实例时,将返回此值。 How can I use REGEXP operator to only match a string with two instances of the letter a , no more and no less? 如何使用REGEXP运算符仅将一个字符串与字母a两个实例进行匹配,且不多也不少?

I have tried to read the documentation but I can't wrap my head around the descriptions for the symbols used in regular expressions 我已经尝试阅读文档,但是我无法将正则表达式中使用的符号的描述笼罩在脑海中

Try this: 尝试这个:

^([^a]*a){2}[^a]*$

Here is Demo 这是演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM