0

I have a field value

"An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague,<img src="mnq.com"> overlapping with those of a letter<img src="xyz.abc">, a paper, an article, a pamphlet, and a short story."

I want to fetch all <img src=""> and replace it with "" from the string collection. How can I write a SQL in MYSQL.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Please explain what this means: *I want to fetch all and replace it with "" from the string collection.*. Sample data and desired results *as text tables* are a big help. – Gordon Linoff Jun 22 '21 at 11:49
  • you can try using regexp_replace() for this. Added this link for reference: https://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql – Arpan Jun 22 '21 at 11:56
  • In output I want this: "An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague, overlapping with those of a letter, a paper, an article, a pamphlet, and a short story." – dibyajyoti sahoo Jun 22 '21 at 12:05
  • Input : An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague, overlapping with those of a letter, a paper, an article, a pamphlet, and a short story. – dibyajyoti sahoo Jun 22 '21 at 12:15

1 Answers1

1

Try this:

SELECT REGEXP_REPLACE(
 "An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague,<img src="mnq.com"> overlapping with those of a letter<img src="xyz.abc">, a paper, an article, a pamphlet, and a short story."
,'<img src=".*">','',1,0,'c'); 
mammad
  • 175
  • 8