jacksp has asked for the wisdom of the Perl Monks concerning the following question:
The sample text may contain video with/without video BB code, so I need to satisfy both conditions and embed in both the cases. Eg: $text= " Video1: http://www.youtube.com/watch?v=dTi4v3HveqE Video2: [video]http://www.youtube.com/watch?v=dTi4v3HveqE[/video]"; Any help on how to merge the 2 regex ?#add video tag to video urls inserted without video tag $text =~ s#(^|\s|\>)((http|https)://www.youtube.com/watch\?\.*v=([a-z0 +-9-_%]+)[&\w;=\+\-]*)#$1\[video\]$2\[\/video\]#isg; #Embed respective video code $text =~ s#\[video\](http|https)://www.youtube.com/watch\?\.*v +=([a-z0-9-_%]+)[&\w;=\+\-]*\[\/video\]#<object class="restrain" type= +"application\/x-shockwave-flash" width="640" height="385" data="http: +\/\/www\.youtube\.com\/v\/$2"><param name="movie" value="http://www.y +outube.com/v/$2"/><param name="wmode" value="transparent"/><embed width="640" height="385" type="app +lication/x-shockwave-flash" src="http://www.youtube.com/v/$2" /></obj +ect>#isg;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Youtube video parser
by Anonymous Monk on Jun 13, 2012 at 07:33 UTC | |
by Anonymous Monk on Jun 13, 2012 at 07:39 UTC |