operator wrong, but I don't understand what the errror is.

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了operator wrong, but I don't understand what the errror is.相关的知识,希望对你有一定的参考价值。

I'm trying to clear text fields from html tags with regex. This query works as expected select REGEXP_REPLACE('

select REGEXP_REPLACE('<span>foobar</span><span><br><br></span>', '<.*?>', ' ', 'g') 

foobar

select REGEXP_REPLACE('<span>foobar</span><span><br><br></span>', '<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6})', ' ', 'g') 

', '

You are mixing greedy and non-greedy quantifiers in the same pattern within the alternatives on the same nesting level, it often leads to ambiguous behavior with PostreSQL regex.

Use greedy quantifiers, the
答案

PostgreSQL demo

, resulting in<.*?> <[^>]*>我试图用regex清除html标签中的文本字段。<[^<>]*>这个查询可以正常工作

select REGEXP_REPLACE(
    '<span>foobar</span><span><br><br></span>', 
    '<[^<>]*>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6})', ' ', 'g')
      ^^^^^^

返回'foobar',但为其他类型的标签增加了变化。返回一个空行。知道为什么吗,看来我用的是

以上是关于operator wrong, but I don't understand what the errror is.的主要内容,如果未能解决你的问题,请参考以下文章

HOperatorSet.DispText函数报错:Wrong window type in operator disp_text

HOperatorSet.DispText函数报错:Wrong window type in operator disp_text

WRONGTYPE Operation against a key holding the wrong kind of value

redis 报Operation against a key holding the wrong kind of value警告的解决方法

Redis发生异常WRONGTYPE Operation against a key holding the wrong kind of value

Redis报错:ERR Operation against a key holding the wrong kind of value 解决处理