XF 2.2 Old [AME] bbcode from vBulletin board: replace it with new [MEDIA]

Scandal

Well-known member
I'm planning to import a vBulletin 3 board to my xF2.2 site.
I have stack on this issue:
There are ~9000 posts with the following bbcode from an old vBulletin addon:
Rich (BB code):
[ame="https://www.youtube.com/watch?v=GEPvsn6JA_c"]this is the video title / useless info currently[/ame]
I want to replace / canonicalize it with the new [MEDIA] tag:
Code:
[MEDIA=youtube]GEPvsn6JA_c[/MEDIA]

Any idea?
I just need a REPLACE query with the correct regular expression.
 
Last edited:
Thanks!
I'm in a good way to achieve what I need.

Here is what I enter on the form:
Quick find: [ame=
Regular expression: #\[ame=([^\]]+)\]([^\[]+)\[/ame\]#siU
Replacement string:
Code:
[media=youtube]\1[/media]

The result:
Matched text: [ame="[MEDIA=youtube]zXHPk-ctoYY[/MEDIA]"]tonight i can write the saddest lines - pablo neruda - YouTube[/ame] Replacement:
Code:
 [media=youtube]"http://www.youtube.com/watch?v=zXHPk-ctoYY"[/media]

My question:
1. how could I remove the "" (quotes) on the \1 (the youtube url insde the replacement bbcode) ?
Sorry, I don't have knowledge of regular expressions.
2. How I can get the youtube id instead of the full url?
 
ok I found this on the addon's discussion. Problem solved :)
Code:
[ame=
#(?:\[ame="[^\.]+\.youtube\.com/watch\?v=)([a-z0-9_-]{11})(?:(?:.*?(?!"]?)).)?(?:"])(?:.*?(?!\[/ame]?).)(?:\[/ame])#siu
[media=youtube]\1[/media]
 
Top Bottom