0

I am in the process of a migration between CMS and the old forum I used embedded attachments using [attachment=attachment#]imageURL[/attachment] and I want to update this where it changes the old attachment tags into [img][/img]

Getting the [/img] tag replaced was easy given that it's a single string. But my problem is that there is a unique numerical value with a range from 1-4000 in the first part of the shortcode eg: [attachment=3789]picture.jpg[/attachment]

Is there a way for me to run a similar replace query that either ignores all the numbers in the first tag and just replaces it, or perhaps something that removes the entire number rage within that part of the string.

I am unable to replace all numerical ranges in that field because the image names may have numerical values in them, so it will need to replace the numerical range only within that tag.

jarlh
  • 42,561
  • 8
  • 45
  • 63
xmesox
  • 11
  • 1
  • 1
    What [tag:rdbms] are you using? – Mureinik Mar 30 '15 at 07:05
  • Can there be many `[attachment=attachment#]imageURL[/attachment]` tags in one value stored in DB? – Kirill Slatin Mar 30 '15 at 07:11
  • A single field can contain several of the tags. I migrated to wordpress so these attachment tags are actually embedded within the post_content fields along with the text of the post itself. But each attachment tag is made unique by the number in the opening tag – xmesox Mar 30 '15 at 07:15
  • With multiple instances of replacement pattern in a single value I don't believe there exists a way to do it without regular expressions. Regexp replace doesn't seem to exist in MySql. Hope [this post](http://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql) will help – Kirill Slatin Mar 30 '15 at 07:54
  • Do you want to replace `[attachment=3789]picture.jpg[/attachment]` with `[img]picture3789.jpg[/img]` ? If not, what is expected output? – Maciej Los Mar 30 '15 at 08:36
  • And another question: Do you want to do that using clear SQL or you can use any .net language (C#, VB.net)? – Maciej Los Mar 30 '15 at 08:38
  • Maciej, that is correct. I am hoping to achieve exactly that. Preferably I'd like to do it using clear SQL. My programming isn't great as it is ;) – xmesox Mar 30 '15 at 08:50

0 Answers0