Update Urls (iframe) in database with REGEXP to new path

So i need a update urls in my database.

I have a 'forums_post' table nad 'post' column. I would like to replace all links with a new path.

Current path:

<iframe scrolling="no" src="http://mik.com/my-topic-title-test-t32/?tab=comments&amp;do=embed&amp;comment=438&amp;embedComment=438&amp;embedDo=findComment#comment-438"></iframe>

New path:

<iframe scrolling="no" src="http://mik.com/topic/my-topic-title-test-32/?tab=comments&amp;do=embed&amp;comment=438&amp;embedComment=438&amp;embedDo=findComment#comment-438"></iframe>

The point is to add /topic/ after http://mik.com and remove "t" from eg. -t32/

Please help ;(

1 answer

  • answered 2018-11-14 13:37 Matt.G

    Try Regex: (http:\/\/mik\.com)\/([A-Za-z-]+?)([a-z])(\d+)\/

    and replace with : \1/topic/\2\4/

    Demo