-
August 2nd, 2011, 02:34 AM
#1
How to find regex expression for a string
string str=@"MODULE: X
AVAILABLE BYTES: 3121152
MODULE: Y
ABC
DEF
GHI34
JKL.23
AVAILABLE BYTES: 3121152";
Regex moduleMemory = new Regex("MODULE: Y + .*AVAILABLE BYTES: ([0-9]*)", RegexOptions.Singleline);
Match match = moduleMemory.Match(dataFromDevice);
String mem = match.Groups[0].Value;
I need to fetch MODULE: Y Available bytes but i guess regular expression is not proper.no match is found.can any one help me to find out regex expression?
-
August 2nd, 2011, 02:54 PM
#2
Re: How to find regex expression for a string
Well, halfway
Regex won't retrieve everything for you - it is just a string filtering system. On MSDN there are literally millions of examples on how to use RegEx. I also think you'll need to do some string manipulation, like for instance, use String.Substring to retrieve the "Module" part.
I hope it helps
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|