I need to match the following full string using Regular Expression :

load "\fiostvmercury\Src\fiostv\server\Admin Console\Build"

Let me know

Um, you could put exactly that in (with double \\ marks obviously) why what problem you having with it?


I used pattern as the below. The complete text is a multiline string and the serach pattern can occur in any of these lines. So wherever the string starts with load , I would require to print the whole line of it.

Regex reg = new Regex(@"^load", RegexOptions.Multiline);

OK, so what happened when you did it..
You know how it goes show your code, show what happened, show what you found but werent expecting..


Have a text file with the following contents :

Hi just a test text
load \fiostvmercury\Src\fiostv\server\Build
load \fiostvmercury\Src\fiostv\server\WFAdminConsole\Build
load "\fiostvmercury\Src\fiostv\server\Admin Console\Build"

Now, you can use the following code :

StreamReader sr = new StreamReader("D:\\ViewStorage\\cc.txt");
            string regmatch = @"^load";
            string output = sr.ReadToEnd();
            MatchCollection mc;
            mc = Regex.Matches(output, regmatch,RegexOptions.Multiline);
            if (mc.Count > 0)
                for (int i = 0; i < mc.Count; i++)

So, you didnt bother with the other half of my post then.
You dont seem to be debugging your code, as you dont seem to be able to show me what you found.. only that "heres some code, you look for yourself."


Thanks for your co-operation so far. The above code which was posted printed "load" thrice , but my expectation was to print the whole line starting with "load".
However, I have done away with regular expressions and is reading the text line by line using StreamReader and wherever it starts with load I get it .
May be it is not a bad idea, if I can get the regular expression to work .

regexpressions arent hard, but rather than just stumble about go to http://RegExpStudio.com and play with the studio product, it will help you undertand more.