Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3405680
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:32:07+00:00 2026-05-18T05:32:07+00:00

I have a sql query in MySQL and I want an expression that matches

  • 0

I have a sql query in MySQL and I want an expression that matches with the string not between ‘<‘ and ‘>’. For example:

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

I tried with below but no luck. I guess because the ‘*’ is greedy.

select '...' rlike '[^[.<.]]?[^[.>.]]*platform[^[.<.]]*[^[.>.]]?' # This expression doesn't work

I knew that the expression would be like below if it’s run on a programming language like Ruby or 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

I found a similar post but I can’t rewrite it for my case.

Could you help me how to come up with the expression that matches string not inside html tag purpose (run in mysql rlike operator) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:32:07+00:00Added an answer on May 18, 2026 at 5:32 am

    Unfortunately, regular expressions cannot reliably parse infinite-descent languages like HTML. You will want to use a proper HTML parser for this, and I doubt MySQL contains one.

    You might consider, if performing this operation in the DB is absolutely critical, creating another column that will contain only the textual representation of the HTML (again, using a proper parser to remove all of the tags) and set that when inserting/modifying the HTML itself. You will obviously need to keep them in sync, and this may be a pain, but it will simplify your queries immensely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL SQL query that selects products and the text translations: SELECT
In my SQL database I have a query that turns values in multiple rows
i have sql query select * from Roles Join Users On Roles.Role=Users.RoleId it return
i have this sql query select * from table where name like ? but
I have an sql query like this: SELECT IF( (SELECT COUNT(*) FROM `test_table2` WHERE
I have this SQL query from the logs select content = 5%id%201=1 from pages
I have a SQL query where I want to insert multiple rows in single
I have a big giant sql query where I select and format a bunch
I have a database that have two tables. The sql query fetching data correctly.
I have some problems with writing a SQL query for MySQL. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.