473,508 Members | 3,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# regular expression multi rows

3 New Member
I have a multiple row string that i want to match from somewhere in the string to the first occurance of another word.

String = "Error Message: This is an error message and the error code for this is 443.
Error_ID = 999-Affd
Solution: Check mainTable 33."


So i want to grab "Error Message:" as the keyword to find then include all the text up to the word Solution
Something like:
Regex re = new Regex(@"Error Message:.*\n ??????", RegexOptions.IgnoreCase);
not sure what to put in for the ??????
Feb 12 '08 #1
3 1629
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Since you know that the string has to start with "Error Message"

you coud check it like

Expand|Select|Wrap|Line Numbers
  1. string theMessage ="";
  2. If (errorString.StartsWith("Error Message") == true)
  3. {
  4.    theMessage = errorString.Replace("Error Message :","");
  5. }
if you do want to use regular expression Im not sure how the regex would look like but will have to look something like

"$[E]{1}[r]{2}[o]{1}[r]{1}[ ]{1}[M]{1}[e]{1}[s]{2}[a]{1}[g]{1}[e]{1}"

but im not sure about it! (regular expression is not anywhere near my strong or weak point :P )
Feb 13 '08 #2
Sandason
3 New Member
Thanks for your input, i already have the ability to grab all instances of "error message" and everything on the same line after it up to a new line but nothing that will grab everything afterwards with say 1 or 2 new lines ending with the word "solution" this is where my issue is.
Feb 13 '08 #3
Sandason
3 New Member
String = "Error Message: This is an error message and the error code for this is 443.
Error_ID = 999-Affd
Solution: Check mainTable 33."

I think i found my solution
Regex re2 = new Regex(@"Error Message:.*?Solution", RegexOptions.Singleline);
Feb 22 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
18782
by: Rob | last post by:
Hello all, If I have the following code fragment: /* comment bla bla */ ....code... With a regular expression, how do I get/extract the comment inside this multi line comment block. With...
0
329
by: Duncan Grisby | last post by:
Hi, I have encountered a problem with the re module. I have a multi-threaded program that does lots of regular expression searching, with some relatively complex regular expressions....
3
2552
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
25
5130
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
1759
by: othellomy | last post by:
I am trying to exclude all strings that has 'a' inside (I have simplified the actual problem) select 1 where 'bb b a dfg' like '%%' However, the above does not work. By the way, I can not use...
3
1817
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular...
2
269
by: Mr.Steskal | last post by:
I need help writing a regular expression that only returns part of a string. For Example I have a multi-line text fragment like below: PC ADVISORS, LC 1234 MT. PARMA ROAD. SUITE A1...
18
622
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
6175
by: altavim | last post by:
Usually when you make regular expression to extract text you are starting from simple expression. When you got to know target text, you are extending your expression. Subsequently very hard to ready...
7
2516
by: wagswvu | last post by:
I have created a regular expression to validate dates in MM/DD/YYYY, MM/YYYY, and YYYY. "((0|1)((0||3))?)?(19|20)\d\d" . How can I make this expression work with a multi-line textbox, so that a user...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.