MyBB Community Forums
Looking for help with advanced MyCode replacement - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Resources (https://community.mybb.com/forum-8.html)
+--- Forum: MyCodes (https://community.mybb.com/forum-117.html)
+--- Thread: Looking for help with advanced MyCode replacement (/thread-95932.html)



Looking for help with advanced MyCode replacement - Monaco - 2011-06-06

Hello,
As the AutoMedia plugin stopped embedding Vimeo for some reason, I am trying to create a MyCode that does the job. I would like to do it the best way: taking a simple URL and converting it into an embedded video with no [] [/] tags at all. I am trying NOT to use the standard [MyCode] tags.

I cannot get the replacement to work, and have not been able to find a good example or tutorial to help.

Here's what I have:

Regular Expression:
http://vimeo.com/(.*?)

Replacement:
<iframe src="http://player.vimeo.com/video/$1?title=0&amp;byline=0&amp;portrait=0&amp;color=ae4815" width="480" height="270" frameborder="0"></iframe>

Test Input:
http://vimeo.com/24410924

Test Result:
<iframe src="http://player.vimeo.com/video/?title=0&amp;byline=0&amp;portrait=0&amp;color=ae4815" width="480" height="270" frameborder="0"></iframe>24410924

The problem is that it's not doing the replacement; it's not putting the video id number at the $1, and leaves the video id number at the end of the output.

Experimenting, I found that this kind of replacement DOES WORK when I put a single space after the Regular Expression AND after the Test Input. What does this tell me? I'm not exactly sure, but I think it needs a known character for closure. I would like to avoid that however... perhaps I could tell it to replace only a string of numbers and end input if anything else is encountered?

This seems to be an advanced problem and I would appreciate any help or guidance.

Thanks Smile


RE: Looking for help with MyCode replacement - Yaldaram - 2011-06-06

Regular expression should be like this;
\[vimeo\](.*?)\[/vimeo\]



RE: Looking for help with advanced MyCode replacement - Aries-Belgium - 2011-06-06

Is it always a number? Then you can do this:
\[vimeo\]([0-9+?)\[/vimeo\]
And paste the id between the mycode.


RE: Looking for help with advanced MyCode replacement - Monaco - 2011-06-06

Did anyone read the part where I didn't want the standard closing and ending myCode tags?


RE: Looking for help with advanced MyCode replacement - Aries-Belgium - 2011-06-06

Try this then:
\<a\ href=\"http\://(?:www\.)?vimeo\.com\/([0-9]+?)[\"\/].*?\>.*?\</a\>

By the time that MyBB will be applying the custom mycode, it already turned all url into links.


RE: Looking for help with advanced MyCode replacement - Monaco - 2011-06-06

Thanks- it was my understanding that we didn't need "\" before every forward slash "/"


RE: Looking for help with advanced MyCode replacement - Aries-Belgium - 2011-06-06

(2011-06-06, 03:36 PM)Monaco Wrote: Thanks- it was my understanding that we didn't need "\" before every forward slash "/"

You don't need it but it works either way. But it's not necessary indeed. Also take not that I forgot something in my previous post. I added it just now.


RE: Looking for help with advanced MyCode replacement - Monaco - 2011-06-06

(2011-06-06, 03:39 PM)Aries-Belgium Wrote:
(2011-06-06, 03:36 PM)Monaco Wrote: Thanks- it was my understanding that we didn't need "\" before every forward slash "/"

You don't need it but it works either way. But it's not necessary indeed. Also take not that I forgot something in my previous post. I added it just now.

Thank you. Thank you! You solved it perfectly. I would have not thought of myBB rendering the link first!

MyCode can be so powerful and make things like video embedding so easy!


RE: Looking for help with advanced MyCode replacement - Aries-Belgium - 2011-06-06

(2011-06-06, 03:46 PM)Monaco Wrote: Thank you. Thank you! You solved it perfectly. I would have not thought of myBB rendering the link first!

MyCode can be so powerful and make things like video embedding so easy!

No problem Wink


RE: Looking for help with advanced MyCode replacement - Monaco - 2011-06-06

(2011-06-06, 04:18 PM)Aries-Belgium Wrote:
(2011-06-06, 03:46 PM)Monaco Wrote: Thank you. Thank you! You solved it perfectly. I would have not thought of myBB rendering the link first!

MyCode can be so powerful and make things like video embedding so easy!

No problem Wink

Rep inbound Smile