Reputation: 4966
I would like to split a body of text such as:
var str = "This is one. Two because of space break
This is number three!
And Four?!?!"
Using str.match( /[^\.!\?]+[\.!\?]+/g )
from here I get the following 3.
[ 'This is one.',
' Two because of space break\r\n This is number three!',
' \r\n\r\n\r\n And Four?!?!' ]
Instead I would like to have 4 different and clean (no \r\n) values because of the page break. I tried using str.replace(/\r?\n/g,'.');
before the match function and that sort of works, but I was wondering if there was a cleaner way maybe by combining regexes?
I would like to get:
['This is one.', 'Two because of space break', 'This is number three!', 'And Four?!?!']
Upvotes: 0
Views: 687