1

So am trying to do a basic bbcode parsing (just for embed tag) but it's been a while I didn't play around with regexp so I'm asking help on this one. I'd like to match all [embed]...[/embed] so I use:

var regexp = new RegExp(/\[embed\].*\[\/embed\]/ig);
console.log(regexp.test(content));


I got many false while I should only have true.

Jsfiddle available here : http://jsfiddle.net/5rxu5/3/

2 Answers 2

1

This should work:

var reg = new RegExp(/\[embed\](.*?)\[\/embed\]/i);
$('.wmd-output').each(function() {
    var content = $(this).html();
    alert(reg.test(content));
});

Here is the jsfiddle link which alerts true for all cases: http://jsfiddle.net/UVy45/

Sign up to request clarification or add additional context in comments.

Comments

0
var regexp = new RegExp(/\[embed\](.*)\[\/embed\]/ig);
console.log(regexp.test(content));

1 Comment

Alerting the same false in the jsfiddle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.