简体   繁体   English

使用REGEXP进行搜索,MySQL中没有重复字符

[英]Search using REGEXP with no repeating characters in mysql

I have a databse of english words and i want to use regexp to search in this database i used this query : 我有一个英文单词数据库,我想用regexp在这个数据库中搜索,我使用了这个查询:

SELECT * FROM `english` WHERE CHAR_LENGTH(words)=4  AND  `words` REGEXP '^[oofd]+$'

it is working and its selecting the words like food,foo,of,do but it is also selecting the words like fooo with 3 o's but in my regexp there is just 2 o's what is the right regular expression to select words with no repeating characters 它正在工作并且选择了诸如food,foo,of,do类的单词food,foo,of,do但它也选择了具有3 o的fooo之类的fooo ,但是在我的正则表达式中只有2 o是选择不带重复字符的单词的正确正则表达式
if there is two character for example oo it will select just words with two o or 1 or zero , not three or more 如果两个字符例如 oo它会选择只用两个字o1 ,而不是三个或更多

I looked in the internet i came with this: 我在互联网上看到了这个:

^(?:([oofd])(?!.*\1))

but it gives me an error: 但这给了我一个错误:

#1139 - Got error 'repetition-operator operand invalid' from regexp #1139-从正则表达式中得到错误“重复运算符操作数无效”

Check for the presence of two vowels in sequence and the absence of three or more vowels in sequence: 检查在序列和不存在序列三个或更多个元音的两个元音的存在

SELECT *
FROM english
WHERE
    words REGEXP '^.*[aeiou]{2}.*$' AND
    words NOT REGEXP '^.*[aeiou]{3}.*$'

If you only want to look for certain repeated vowels, you should be able to adapt this answer fairly easily. 如果您只想查找某些重复的元音,则应该能够轻松轻松地调整此答案。

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

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