- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我想查询一个酒名数据库,其中很多都包含重音符号(但不是以统一的方式,所以类似的 Wine 可能带有或不带有重音符号)
基本查询如下所示:
SELECT * FROM `table` WHERE `wine_name` REGEXP '[[:<:]]Faugères[[:>:]]'
这将返回标题中包含“Faugeres”但不包含“Faugeres”的条目
SELECT * FROM `table` WHERE `wine_name` REGEXP '[[:<:]]Faugeres[[:>:]]'
相反。
我的想法是这样的:
SELECT *
FROM `table`
WHERE `wine_name` REGEXP '[[:<:]]Faug[eèêéë]r[eèêéë]s[[:>:]]'
可能会成功,但这只会返回没有重音符号的结果。
该字段整理为 utf8_unicode_ci,根据我的阅读,它应该是这样的。
有什么建议吗?!
最佳答案
Warning
The REGEXP and RLIKE operators work in byte-wise fashion, so they are not multi-byte safe and may produce unexpected results with multi-byte character sets. In addition, these operators compare characters by their byte values and accented characters may not compare as equal even if a given collation treats them as equal.
[[:<:]]
和 [[:>:]]
正则表达式运算符是单词边界的标记。使用 LIKE
可以达到的最接近的值运营商是这一行的东西:
SELECT *
FROM `table`
WHERE wine_name = 'Faugères'
OR wine_name LIKE 'Faugères %'
OR wine_name LIKE '% Faugères'
正如您所见,它并不完全等价,因为我将单词边界的概念限制为空格。为其他边界添加更多子句将是一团糟。
您也可以使用全文搜索(虽然不一样),但您不能在 InnoDB 表中定义全文索引(目前)。
你肯定不走运:)
附录:此has changed从 MySQL 8.0 开始:
MySQL implements regular expression support using International Components for Unicode (ICU), which provides full Unicode support and is multibyte safe. (Prior to MySQL 8.0.4, MySQL used Henry Spencer's implementation of regular expressions, which operates in byte-wise fashion and is not multibyte safe.
关于MySQL REGEXP 查询 - 不区分重音的搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14137273/
我对这里的区别是什么以及为什么一个有效而另一个无效感到困惑。谁能解释一下? //The string to search through var str = "This is a string /*
我很困惑这里有什么区别以及为什么一个有效而另一个无效。有人能解释一下吗? //The string to search through var str = "This is a string /* w
概述 RegExp 的构造函数创建了一个正则表达式对象,用模式来匹配文本。 有关正则表达式介绍,请阅读JavaScript指南中的正则表达式章节。 语法 文字和构造符号是可能的: /patt
在我的数据库中,我有一个公司表。该表有一个名为 tags 的字段,其中包含以下内容: Furniture Retail E-commerce B2C Home & Furniture Consumer
var str='The_Andy_Griffith_Show'; // string to perform replace on var regExp1=/\s|[A-Z]/g; var reg
我正在为 VBA 编写一个脚本,用于 Outlook 2013,它使用正则表达式,我发现的每个示例似乎都使用 Set regex = New RegExp创建一个 RegExp 对象。当我尝试这个时,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 4 年前。
在“How do I removing URLs from text?”中建议使用以下代码: require 'uri' #... schemes_regex = /^(?:#{ URI.scheme
所以我有一个 RegExp regex =/asd/ 我将它作为 key 存储在我的键值对存储系统中。 所以我说 str = String(regex) 返回 "/asd/"。 现在我需要将该字符串转
谁能提供一些例子来解释 regexp.Compile 之间的区别?和 regexp.CompilePOSIX ?我阅读了文档。但是我无法得到直观的理解。 最佳答案 Perl 和 POSIX 兼容的正则
我目前正在学习 SQL 并使用 SSMS 2017。我不明白为什么在使用 REGEXP 语法时出现错误,它似乎适用于其他任何人: SELECT * FROM List WHERE Name REGEX
我有一个包含文本的 emacs 缓冲区 a1b2c3 使用正则表达式构建器,我创建了正则表达式 "b\\(2\\)" 并且可以看到匹配突出显示(b2,2 的颜色不同)。 但是,当我将表达式粘贴到 re
这个问题已经有答案了: JavaScript: using constructor without operator 'new' (2 个回答) 已关闭 7 年前。 RegExp('hi') 和有什么
我的正则表达式是这样的: ((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?([a-z]) 如果我将其作为 MySQL R
我对基准测试和功能感兴趣?是否有理由使用 Jakarta 正则表达式? 最佳答案 似乎没有什么理由。但是除了 Jakarta 图书馆之外,还有其他一些有趣的图书馆。此链接提供了一些有关性能和 perl
如果声明了 SPEC Env,我将尝试有条件地加载我的测试: var context = null if (process.env.SPEC) { context = require.contex
我尝试为 emacs 编写一些新的对齐规则,但发现这种奇怪且不一致的行为。当前缓冲区内容: "some thing" like => this hello => world and => aga
这个问题在这里已经有了答案: Is gcc 4.8 or earlier buggy about regular expressions? (3 个答案) 关闭 8 年前。 我尝试使用 C++11
我遇到了两个错误,都与编码有关并且都相关。 我在启动 WEBrick 时遇到的第一个错误(技术上是警告): /Users/USERNAME/example/config/initializers/bb
我有一个 almost-json文件。估计1000 行。这是其中的一部分: level: { 1: { cost: 200,
我是一名优秀的程序员,十分优秀!