1

Currently I have this regex to split a paragraph into sentences: /[^\.!\?]+[\.!\?]+/g. The issue though is that my paragraphs aren't just paragraphs of text. I have links in them like this:

This is text and here is a <value="link" href="http://link.com?param=test"> which directs to another page. So I don't want to split at the anything inside the link above.

I want to split that into an array like:

['This is text and here is a <value="link" href="http://link.com?param=test"> which directs to another page.', 'So I don't want to split at the anything inside the link above.']

What regex would do this?

chromedude
  • 4,246
  • 16
  • 65
  • 96

1 Answers1

1

Try this:

(.+?[\.!\?](?!.+?>)\s*)
Skpd
  • 670
  • 3
  • 17
  • This seems to work pretty well, but forgets about the last text if it doesn't terminate in the expected punctuation when splitting. – Namey Jan 08 '15 at 08:15