【发布时间】:2010-11-21 05:54:10
【问题描述】:
我在 MySQL 中有一个 sql 查询,我想要一个与不在 '' 之间的字符串匹配的表达式。例如:
select '<span class="boldtext">collaboratively site</span> – regardless of platform or language' rlike 'expression looking for boldtext' ==> should return false because 'boldtext' locates inside a html tag
select '<span class="boldtext">collaboratively site</span> – regardless of platform or language' rlike 'expression looking for platform' ==> should return true because 'platform' locates outside a html tag
我尝试了以下但没有运气。我猜是因为'*'是贪婪的。
select '...' rlike '[^[.<.]]?[^[.>.]]*platform[^[.<.]]*[^[.>.]]?' # This expression doesn't work
我知道如果在 Ruby 或 PHP 等编程语言上运行,表达式会如下所示
'<span class="boldtext">collaboratively site</span> – regardless of platform or language' =~ /((?!<[^>]*))\bboldtext\1/ # => false
'<span class="boldtext">collaboratively site</span> – regardless of platform or language' =~ /((?!<[^>]*))\bplatform\1/ # => true
我找到了similar post,但我无法为我的情况重写它。
你能帮我想出匹配字符串的表达式,而不是在 html 标记目的内(在 mysql rlike 运算符中运行)吗?
【问题讨论】: