如何选择最后没有点的段落并删除 - 使用jQuery/javascript?

Tom*_*eus 1 javascript regex jquery

我有以下段落:

<p>This is a first paragraph.</p>
<p>This is a second</p>
<p>A third paragraph is here.</p>
<p>And a fourth</p>
Run Code Online (Sandbox Code Playgroud)

第二段和第四段在句末没有句号.有没有办法选择这些段落然后用jquery/javascript删除它们?

fca*_*ran 8

$('p').each(function() {
   var par = $(this), text = par.text();
   if (text.charAt(text.length-1) !== '.') {
      par.remove();
   }
});
Run Code Online (Sandbox Code Playgroud)

当然它在点和段落末尾之间不需要额外的空格(或其他字符):在这种情况下,正则表达式检查而不是charAt()更好的选择