Steve Posted January 14, 2015 Share Posted January 14, 2015 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? Quote Link to comment Share on other sites More sharing options...
Guest rasteri Posted January 14, 2015 Share Posted January 14, 2015 try : ^(http|https):\/\/(www.)?instagram.com\/p\/([a-zA-Z]+) Quote Link to comment Share on other sites More sharing options...
Guest rasteri Posted January 14, 2015 Share Posted January 14, 2015 Or ^(http|https):\/\/(www.)?instagram.com\/p\/([a-zA-Z0-9]+)if instagram uses numbers in its video codes (I can't find any info on it) Quote Link to comment Share on other sites More sharing options...
Steve Posted January 14, 2015 Author Share Posted January 14, 2015 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". Quote Link to comment Share on other sites More sharing options...
Guest rasteri Posted January 14, 2015 Share Posted January 14, 2015 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 1 Quote Link to comment Share on other sites More sharing options...
Steve Posted January 14, 2015 Author Share Posted January 14, 2015 That appears to have done the trick! Thanks man. Quote Link to comment Share on other sites More sharing options...
Guest rasteri Posted January 14, 2015 Share Posted January 14, 2015 No worries. Quote Link to comment Share on other sites More sharing options...
JHouse Posted January 21, 2015 Share Posted January 21, 2015 Nice! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.