in reply to Youtube video parser
Don't :) I would use Parse::BBCode instead, with a custom tag definition for video, and a custom text_processor / url_finder callback , see example in Parse-BBCode-0.14/t/14_info.t
$text =~ s{ (?: (^|\s|\>) # $1 ( # $2 (http|https) # $3 ://www.youtube.com/watch\?\.*v= ([a-z0-9-_%]+) # $4 [&\w;=\+\-]* ) ) | (?: \Q[video]\E (^|\s|\>) # $5 ( # $6 (http|https) # $7 ://www.youtube.com/watch\?\.*v= ([a-z0-9-_%]+) # $8 [&\w;=\+\-]* ) \Q[/video]\E ) }{ my $ret = ""; my $https = $3 || $7; my $vid = $4 || $8; $ret .= "<embed>"; $ret .= escapeHTML($vid); $ret .= "</embed>"; $ret; }gmsxie;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Youtube video parser
by Anonymous Monk on Jun 13, 2012 at 07:39 UTC |