M
M
Maxim Tsyplenkov2021-04-11 00:38:24
Regular Expressions
Maxim Tsyplenkov, 2021-04-11 00:38:24

How to delete in MYSQL database everything between two tags?

Hello.
There is a site on wordpress on which there are a lot of posts containing

<nav>много разного текста включая разные html теги</nav>.


Tell me how to remove actually this different text between the tags: <nav></nav>either through a sql query or through a plugin?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick Sdk, 2018-06-13
@Jumandjilos

/^\S+$/
add to yours /^[a-zA-Z0-9]+$/?
yours doesn't "allow" spaces anyway, if anything
https://regex101.com/r/6gPPHH/1
https://regex101.com/r/ojb6TT/1

S
Slava Rozhnev, 2021-04-12
@maxim_tsyplenkov

Well, something like this:

update test 
set html = replace(
  	html,
  substr(
    html, 
    locate('<nav>', html, 1) + 5,
    locate('</nav>', html, locate('<nav>', html, 1))-locate('<nav>', html, 1) - 5
  ), '');

SQL example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question