Jump to content

Help with some code


Steve

Recommended Posts

I'm trying to figure out how to get Instagram videos to auto-embed on here.

 

I'm using this code: -

 

Regex: -

^(http|https)://(www.)?instagram.com/p/{3}(x5C)?(x23)?

Replacement match: -

<iframe src="//instagram.com/p/$3/embed/" width="612" height="710" frameborder="0" scrolling="no" allowtransparency="true"></iframe>

The problem with that is, when you right-click on an Instagram video and copy the link, when you paste it you get this: -

 

h**p://instagram.com/p/xxrPeISLsk/?modal=true

 

That just leads to an empty player being embedded, but if you remove "/?modal=true" from the end of the link then it works: -

 

http://instagram.com/p/xxrPeISLsk

 

So, a long shot maybe, but does anyone know how to modify the code above so that it automatically ignores the "/?modal=true" part of the link?

Link to comment
Share on other sites

Thanks for the help, but you have to include a variable in the regex for this to work, so in the case of the code in the first post the variable is {3} in the regex, which then replaces $3 in the second line of code. In this particular case the aim is to capture the string of characters after p/ and before the next /.

 

Right now it captures "xxrPeISLsk/?modal=true", rather than just "xxrPeISLsk", so I need some way to say "ignore the last forward slash and everything that follows it".

Link to comment
Share on other sites

Guest rasteri

Oh is this some weird IPB regex variant? I have no idea then, I tested it using https://www.regex101.com/r/cG0xW5/1

 

I did wonder how you were getting away without escaping the forward slashes, haha.

 

Normally you'd just extract the relevant pattern from the string, which in this case is the 3rd set of brackets. That's why I thought you were using $3.

 

Try :

^(http|https)://(www.)?instagram.com/p/{3}(\/\S+)?
Failing that, do IPB provide any documentation on their regex implementation I can look at? I can't find anything by googling. And I'm bored at work :)
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...