Regex and String Literals?

My goal is to get the source of a webpage (WebClient.DownloadString) and than use a string formatted in regularexpressions in order to get the data I want from the source code.

The problem first occurs when I paste the regex string from notepad/web browser (a tester) into visual studio express 2015 and it randomly adds spaces between things like "[0-9]*" so it would look like "[ 0-9 ] *" Though that was manually fixed.

The options are set for Single and Multiline so that it can search multiple lines and the line break doesn't become a problem when dealing with characters.

I've tested the Regex string in a parser and it works fine. However when I put it into C# and run the app it seems to not match (a regex fail). I can't seem to get the string out of the debugger because it starts throwing a million /n/t and \" escape syntax so it becomes both encoded for machines only and no parser that i've seen so far can figure it out.

Any ideas on what I'm doing wrong?

Note: This is my regex string without the escapes "<li class="result">.?<article>.?<h1>.?<a href="(?<game_url>.?)" class="result-link" data-pos="[0-9]">(?<game_title>.?)<.a>.*?<.h1>".

When it's put into C# I need to change all the " to \" or else it won't run (errors). No I do not escape the first and last quote.

by venumtenebris via /r/csharp

Leave a Reply