Javascript 正则表达式从中提取所有匹配值,以开头和结尾

Javascript 正则表达式从中提取所有匹配值,以开头和结尾,javascript,node.js,regex,Javascript,Node.js,Regex,我有一个如下字符串的html页面 "<div id="app"> <section> <esi:include src="http://example.com/LICENSE" /> </section> <section> <esi:include src="http://test.com/LICENSE" /> </section> </d

我有一个如下字符串的html页面

  "<div id="app">
    <section>
      <esi:include src="http://example.com/LICENSE" />
    </section>
    <section>
      <esi:include src="http://test.com/LICENSE" />
    </section>
  </div>"
尝试以下解决方案:

str = new String('<div id="app"><section><esi:include src="http://example.com/LICENSE" /></section><section><esi:include src="http://test.com/LICENSE" /></section></div>');    
array = str.match(/<esi:include(\s+(.*?)\s*\/>)/g);    
console.log(array);
str=新字符串(“”);
数组=str.match(/)/g);
console.log(数组);
尝试以下解决方案:

str = new String('<div id="app"><section><esi:include src="http://example.com/LICENSE" /></section><section><esi:include src="http://test.com/LICENSE" /></section></div>');    
array = str.match(/<esi:include(\s+(.*?)\s*\/>)/g);    
console.log(array);
str=新字符串(“”);
数组=str.match(/)/g);
console.log(数组);

如果html是多行的,则此操作有效。但在我的服务器端呈现中,整个html将在一行中呈现。"". 请为所有情况提供解决方案。我已修改解决方案以使用非贪婪重复(.*)。这将匹配空格之间可能的最短字符串…如果html是多行的,这将起作用。但在我的服务器端呈现中,整个html将在一行中呈现。"". 请为所有情况提供解决方案。我已修改解决方案以使用非贪婪重复(.*)。这将匹配空格之间可能最短的字符串。。。