Reputation: 7109
How can I apply regular expression to filter only
[video src="http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v" width="480" height="360" id="b-test" class="player" ]
from the following string
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.
or Without using regular expression and Dom is there anyways to get the same
Upvotes: 1
Views: 1212
Reputation: 886
preg_match("/\[video[^\]]+\]/i", $subject, $matches);
$matches[0]
contains
[video src="http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v" width="480" height="360" id="b-test" class="player"]
Upvotes: 0
Reputation: 54884
Use substring and indexOf
for example,
htmlString = document.getElementById('div').innerHtml();
startIndex = htmlString.indexOf("[video");
endIndex = htmlString.indexOf("]", startIndex);
output = htmlString.substring(startIndex, endIndex);
Upvotes: 0
Reputation: 9387
That's a shortcode and you can easily use the WordPress Shortcode API to handle those shortcodes:
function video_shortcode( $atts, $content = null ) {
// do whatever you want to to
}
add_shortcode('video', 'video_shortcode');
In the $atts
array you will have a list of all of your attributes from the video shortcode:
array(
"src" => "http://duel.evotechaustin.com/wp-content/uploads/2010/09/kramer.m4v",
"width" => "480",
"height" => "360",
"id" => "b-test",
"class" => "player"
)
Upvotes: 1