Как применить регулярное выражение только к фильтру
[video src="http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v" width="480" height="360" id="b-test" class="player" ]
из следующей строки
Is simply dummy text of the printing and typesetting industry. [video src="http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v" width="480" height="360" id="b-test" class="player" ] Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
или без использования регулярных выражений и Dom в любом случае получить то же самое
Это короткий код, и вы легко можете использовать WordPress Shortcode API для обработки этих коротких кодов:
function video_shortcode( $atts, $content = null ) { // do whatever you want to to } add_shortcode('video', 'video_shortcode');
В массиве $atts вы получите список всехатрибуты из шорткода видео:
$atts
array( "src" => "http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v", "width" => "480", "height" => "360", "id" => "b-test", "class" => "player" )
Используйте подстроку и indexOf
, например,
htmlString = document.getElementById('div').innerHtml(); startIndex = htmlString.indexOf("[video"); endIndex = htmlString.indexOf("]", startIndex); output = htmlString.substring(startIndex, endIndex);
preg_match("/\[video[^\]]+\]/i", $subject, $matches);
$matches[0] содержит
$matches[0]
[video src="http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v" width="480" height="360" id="b-test" class="player"]