Extract text between paragraph tag using RegEx
express, javascript, node.js, regex
Solution
There is no "capture all group matches" (analogous to PHP's `preg_match_all`) in JavaScript, but you can cheat by using `.replace`:
var matches = [];
html.replace(/<p>(.*?)<\/p>/g, function () {
//arguments[0] is the entire match
matches.push(arguments[1]);
});
Problem
I try to extract text between parapgraph tag using RegExp in javascript. But it doen't work... My pattern: ``` <p>(.*?)</p> ``` Subject: ``` <p> My content. </p> <img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTJ9ylGJ4SDyl49VGh9Q9an2vruuMip-VIIEG38DgGM3GvxEi_H"> <p> Second sentence. </p> ``` Result : ``` My content ``` What I want: ``` My content. Second sentence. ```