I have a document containing lots of paragraphs. Some of these are subheadings, which are identifiable because they do not end with a full stop, like this:
<p>This is a title</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a title</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a title</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
<p>This is a sentence.</p>
I want to make the titles go into an h3 tag but not the sentences. So I need to find and replace all paragraphs not ending in a full stop. I need to do this with javascript I have tried the following but each fails. In each case the text is first read into a variable called body.
body = body.replace(/<p>(.*?)(?!\.)<\/p>/gi, "<h3>$1</h3>");
That just makes everything bold
This would work, I think:
body = body.replace(/<p>(.*?)(?<!\.)<\/p>/gi, "<h3>$1</h3>");
but javascript does not recognise negative look behind.
Any ideas how I do this?
([^\.]*?)<\/p>`
– Aug 24 '15 at 17:04([^.]*?)<\/p>`
– DrBloke Aug 25 '15 at 11:321.2 million people like regex
` but as I mention below, this doesn't really matter to me. – DrBloke Aug 25 '15 at 11:57