0

The Text column of my articles table contains html tags, the query returns a false result when I use a SELECT with LIKE:

Here is my request:

SELECT Text FROM articles Text LIKE '%aaa%'

I then try to remove the html tags before doing the LIKE of the SELECT. I tried using regexp_replace but it doesn't work

(SELECT regexp_replace(Text, '<[^>]*>|&nbsp;', '')

If you could help me. Thanks.

MatBailie
  • 83,401
  • 18
  • 103
  • 137
itdev
  • 43
  • 1
  • 6
  • The only way to ***ensure*** you don't get false positives is to parse the html. Don't Do That In SQL. Read this question about extracting text from html in MySQL... https://stackoverflow.com/questions/70973861/how-can-i-extract-text-from-html-in-a-mysql-column *(Instead, parse the html when the data is being ingested and store it in your DB in a more searchable structure.)* – MatBailie Nov 20 '22 at 23:00
  • 1
    Stripping HTML tags from text is a very complex parsing task requiring a full-featured and hopefully debugged HTML/XML parser. Most people don't attempt it with regular expressions. If you must do it with regular expressions, look for appropriate ones online, and tell your users to expect flaws. – O. Jones Nov 20 '22 at 23:03

0 Answers0