Regular Expression help
Hello all,
I need a bit of help with unix regular expressions and I'm far from knowledgeable on this.
I have the following regular expression:
It's essentially parsing a url and pulling bits of information out of it to create the following:
It works perfectly with a url of this format:
However the following format of url does not work
I am smart enough to see that there is a difference in the URL that the regex isn't handling, but I'm not sure how to go about modifying the existing regex to deal with the second url.
I think it would be a tad complicated, if not impossible, to have a single regex for both urls, but if someone knows how to do that, great. Otherwise, if someone can clue me in to what needs to be changed in the regex to deal with the second url I'd appreciate it.
If someone is really bored they could explain what all the portions of the rexeg command are doing. I'm fairly sure it's splitting the url into portions, and gathering/removing stuff based on certain criteria, for example if a portion of the url is alphanumeric.
I need a bit of help with unix regular expressions and I'm far from knowledgeable on this.
I have the following regular expression:
Code:
[http://]*[a-z]*?[\.]?youtube\.[a-z]*?/watch\?v=([A-Z0-9._%-]*)[&\w;=\+_\-]*
Code:
<object width="$ameinfo[width]" height="$ameinfo[height]"> <param name=''movie'' value="http://www.youtube.com/v/$p1&ap=%2526fmt%3D18&fs=1"></param> <param name="allowFullScreen" value="true"></param> <embed src="http://www.youtube.com/v/$p1&ap=%2526fmt%3D18&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="$ameinfo[width]" height="$ameinfo[height]" wmode="transparent"></embed></object>
Code:
http://www.youtube.com/watch?v=XXXX-XxXXxxX
Code:
http://www.youtube.com/v/XXXX-XxXXxxX
I am smart enough to see that there is a difference in the URL that the regex isn't handling, but I'm not sure how to go about modifying the existing regex to deal with the second url.
I think it would be a tad complicated, if not impossible, to have a single regex for both urls, but if someone knows how to do that, great. Otherwise, if someone can clue me in to what needs to be changed in the regex to deal with the second url I'd appreciate it.
If someone is really bored they could explain what all the portions of the rexeg command are doing. I'm fairly sure it's splitting the url into portions, and gathering/removing stuff based on certain criteria, for example if a portion of the url is alphanumeric.
God I hate regex...
They are so complicated but I know they are powerful...
Is your answer not as simple as removing the : "watch\?v=" and replacing with "v/"
[http://]*[a-z]*?[\.]?youtube\.[a-z]*?/v/([A-Z0-9._%-]*)[&\w;=\+_\-]*
They are so complicated but I know they are powerful...Is your answer not as simple as removing the : "watch\?v=" and replacing with "v/"
[http://]*[a-z]*?[\.]?youtube\.[a-z]*?/v/([A-Z0-9._%-]*)[&\w;=\+_\-]*
That's what I thought and I've tried that, but it does not appear to have the desired result. This is actually part of the AME mod for vBulletin, so it could be doing more behind the scenes, but I don't think so. The idea is it'll parse a url in a post, using the regex and then build the appropriate code to allow the video to be embedded in the page.
I used this to see what happened:
Download Reggy for Mac - Visualize what regular expression will match given test string. MacUpdate Mac Editors Software Downloads
It seems to do the same when we use our new version of the expression....
It goes blue when it matches - I dont know
Download Reggy for Mac - Visualize what regular expression will match given test string. MacUpdate Mac Editors Software Downloads
It seems to do the same when we use our new version of the expression....
It goes blue when it matches - I dont know
Yeah, I tried some online regex checker thing and it did the same too! Some people think that the problem started with the upgrade to vBulletin 3.8.3, so it's possible that may be the problem. I've posted on the modification's thread so we'll see if there is a response there too.
Thanks for the help
Thanks for the help
Thread
Thread Starter
Forum
Replies
Last Post
Wingnuttzz
Member's Gallery
30
Apr 26, 2022 11:15 PM
Sambob
Engine Management and ECU Remapping
41
Nov 27, 2015 07:36 PM




