-5

I have to replace over 12000 image links that are ending with .gif with different .gif links.

For example 22_448_7.gif, 342_448_7.gif and I want to replace everything that's after

/wp-content/uploads/2015/09/86_448_7.gif

with

/wp-content/uploads/2015/09/image.gif

admdrew
  • 3,790
  • 4
  • 27
  • 39
Inga
  • 1
  • 5
    This isn't very clear. You want to replace all image links with an image named `image.gif`? Also, what you have tried so far as far as a regex goes? What isn't working? – DavidS Sep 28 '15 at 20:28
  • This does not appear to be a question. – admdrew Sep 28 '15 at 20:31
  • Please review the help page for an [On-Topic](http://stackoverflow.com/help/on-topic) question, as this isn't a "do it for me" site. – AWinkle Sep 28 '15 at 20:40
  • Mysql doesn't have native support for regex replacing last I'd seen. There are user defined functions and libraries that you can add for this; or you could run it through some other language (select from db in PHP, run preg_replace on content, run update). – chris85 Sep 28 '15 at 21:17
  • possible duplicate of [How to do a regular expression replace in MySQL?](http://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql) – chris85 Sep 28 '15 at 21:18
  • well the problem is that i cached exteral images and they were not saved well in to my site .. and now all of them are broke and got saved with different names but all those images contain term "_448_" before and after have numbers by 2 or 3 .. now I need replace that with a new image (image.gif) – Inga Sep 28 '15 at 21:30
  • so images are looking like this wp-content/uploads/2015/09/86_448_7.gif wp-content/uploads/2015/09/862_448_7.gif wp-content/uploads/2015/09/86_448_741.gif and what i want is to replace this term "_448_" that have numbers before _ and after _ with term image – Inga Sep 28 '15 at 21:30
  • You could use the `replace`, https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace, to replace all `_448_`s but aside from that I think your going to need regex replacing. – chris85 Sep 29 '15 at 04:29

1 Answers1

0

Switch to Plan B: Replace them in your application code, not SQL.

Rick James
  • 135,179
  • 13
  • 127
  • 222