| | |
Regular expression required
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2009
Posts: 15
Reputation:
Solved Threads: 0
Hi,
I need to match the following full string using Regular Expression :
Let me know
I need to match the following full string using Regular Expression :
C# Syntax (Toggle Plain Text)
load "\fiostvmercury\Src\fiostv\server\Admin Console\Build"
Let me know
•
•
Join Date: Feb 2009
Posts: 15
Reputation:
Solved Threads: 0
Hi
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.
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.
C# Syntax (Toggle Plain Text)
Regex reg = new Regex(@"^load", RegexOptions.Multiline);
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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..
You know how it goes show your code, show what happened, show what you found but werent expecting..
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Feb 2009
Posts: 15
Reputation:
Solved Threads: 0
He,
Have a text file with the following contents :
Now, you can use the following code :
Have a text file with the following contents :
C# Syntax (Toggle Plain Text)
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 :
C# Syntax (Toggle Plain Text)
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++) { Console.WriteLine(mc[i].Value); } }
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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."
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."
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Feb 2009
Posts: 15
Reputation:
Solved Threads: 0
Lizr,
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 .
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 .
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
![]() |
Similar Threads
- Question about string pattern matching (Java)
- Java Datatypes to SQL Datatypes (Java)
- PHP4 regular expressions? (PHP)
- Help regarding regular expression and codecs module (Python)
- Open In New Window Php (PHP)
- .net validation/javascript conflict (ASP.NET)
- Regular expression (Perl)
Other Threads in the C# Forum
- Previous Thread: how to signal WinForm control input out of range?
- Next Thread: Want to execute a command on all files recursively
| Thread Tools | Search this Thread |
.net access algorithm angle array barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion convert csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum event excel file firefox form format forms function gdi+ httpwebrequest image index input install java label leak libraries list listbox mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






