RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Text File Parser - splits on unquoted \n - backslash escape - \r\n okay
Expression
/^("(\\["\\]|[^"])*"|[^\n])*(\n|$)/gm
Description
JavaScript match() method (or equivalent) creates an array of lines from a text file. This pattern handles lines ending with \r\n as well as \n at the expense of including the line-ending chars in the output. The Matching Examples are ready for enclosure in single quotes. Output from Matching Example 1: [0]=a " b [\n] " c [\n] [1]= Line2... [\n] [2]= Line3... Output from Matching Example 2: [0]=a " b [\r][\n]" c [\r][\n] [1]= Line2... [\r][\n] [2]= Line3...
Matches
a " b \n " c \n Line2... \n Line3... | a " b \r\n " c \r\n Line2... \r\n Line3...
Non-Matches
matches all
Author Rating: Not yet rated. Brian \S\s
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials