regex breaks on \n

Posted by Sourabh on Stack Overflow See other posts from Stack Overflow or by Sourabh
Published on 2010-05-26T08:38:06Z Indexed on 2010/05/26 8:41 UTC
Read the original article Hit count: 235

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex