c# - How to get ignorewhitespaces to work with escape sequences -


if (regex.ismatch(line, "^([\\w\\-\\ ]+)\\ ,([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)", regexoptions.ignorepatternwhitespace)) 

how ignorepatternwhitespace work above. works @" .... " because of amount of quotes , backslashes went " ... " , escape them wth backslashes instead of @" ... " , doubling down quotes. works huge line instead of neat little blocks.

the reason language specification prohibits normal string literal ("normal string literal") spanning lines -- is, may not contain embedded literal newline character.

at-strings this

@"this string spans lines " 

may span lines in above.

what can to take advantage of c#'s constant folding , build string along these lines:

regex foo = new regex(                     " part 1"                   + " part 2"                   + " part 3"                   + ...                 , regexoptions.ignorepatternwhitespace                 ) ; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -