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
Post a Comment