views:

55

answers:

1

hi

segmentText = <input from textarea>;


testRgx = [/( \d+\.| [^\W\d_]\.|.)+?([!?.。](?= |$)|$)/g];


arrSegments = segmentText.match(testRgx);

This expression fails if segmentText has \n or other white spaces in it.I want to add \n in to the list of chars that the above pattern use [!?.。] => [!?.。\n] so that the segment is separated based on the \n character

A: 

If you add the 'm' modifier the . will match newlines

/foo/gm
Sean Kinsey
Thanks it works
Sourabh
Are you going to mark it as the solution then? ;)
Sean Kinsey
The `m` modifier causes `^` and `$` to match at line boundaries. It's `s` that causes the dot to match newlines, but JavaScript doesn't support it.
Alan Moore
hi Alan Moore ..I did not understand the comment..can you please elaborate.How can I make it so that it does not break on \n ?
Sourabh