Click here to Skip to main content
15,890,123 members
Home / Discussions / C#
   

C#

 
GeneralRe: How To Parse This String Pin
Pete O'Hanlon19-Jun-12 22:28
mvePete O'Hanlon19-Jun-12 22:28 
GeneralRe: How To Parse This String Pin
PIEBALDconsult20-Jun-12 3:32
mvePIEBALDconsult20-Jun-12 3:32 
GeneralRe: How To Parse This String Pin
Pete O'Hanlon20-Jun-12 3:48
mvePete O'Hanlon20-Jun-12 3:48 
GeneralRe: How To Parse This String Pin
PIEBALDconsult19-Jun-12 12:36
mvePIEBALDconsult19-Jun-12 12:36 
GeneralRe: How To Parse This String Pin
Pete O'Hanlon19-Jun-12 12:39
mvePete O'Hanlon19-Jun-12 12:39 
GeneralRe: How To Parse This String Pin
Kevin Marois19-Jun-12 12:48
professionalKevin Marois19-Jun-12 12:48 
GeneralRe: How To Parse This String Pin
Pete O'Hanlon19-Jun-12 22:48
mvePete O'Hanlon19-Jun-12 22:48 
GeneralRe: How To Parse This String Pin
Kevin Marois20-Jun-12 5:49
professionalKevin Marois20-Jun-12 5:49 
[EDIT] - Never mind. I'm stupid. I changed it to...

MatchCollection matches = regex.Matches(Line);


Now it works.



Thanks for the code. I'm still getting nothing in the collection. Here's my code:

var Line = "Dev: 0 Model: TOSHIBA MK3265GSX   Serial: 20FDF20WS  FW: GJ002H STW: 0 MaxLBA: 625142447 FDESUPPORTED: 0 PREBOOT: 0 DRIVETRUSTENABLED: 0 DRIVETRUSTSUPPORTED: 0 w128: 41 FULLFW: GJ002H SERVOFW:  SDLSUPPORTED: 1 PLATFORM: 0 SAFE: 1 DSTTIMEOUT: 103 ISBOOTORSYSTEM: 1";
var WordToFind = "Model";

Regex regex = new Regex("(?:(?'Key'\\S+): (?'Value'.*?))",
                    RegexOptions.RightToLeft |
                    RegexOptions.CultureInvariant |
                    RegexOptions.Compiled);

MatchCollection matches = regex.Matches(WordToFind);

foreach (Match match in matches)
{
    Console.WriteLine("Key: {0} - Value: {1}", match.Groups["Key"], match.Groups["Value"]);
}


I'm guessing the regex string is wrong, but kI really don't knnow.
If it's not broken, fix it until it is

GeneralRe: How To Parse This String Pin
Pete O'Hanlon20-Jun-12 6:15
mvePete O'Hanlon20-Jun-12 6:15 
GeneralRe: How To Parse This String Pin
Kevin Marois20-Jun-12 6:33
professionalKevin Marois20-Jun-12 6:33 
GeneralRe: How To Parse This String Pin
Pete O'Hanlon20-Jun-12 8:07
mvePete O'Hanlon20-Jun-12 8:07 
GeneralRe: How To Parse This String Pin
PIEBALDconsult19-Jun-12 12:38
mvePIEBALDconsult19-Jun-12 12:38 
QuestionExcel Chart in C# Pin
Danzy8319-Jun-12 8:56
Danzy8319-Jun-12 8:56 
AnswerRe: Excel Chart in C# Pin
Eddy Vluggen19-Jun-12 9:00
professionalEddy Vluggen19-Jun-12 9:00 
GeneralRe: Excel Chart in C# Pin
Danzy8319-Jun-12 9:04
Danzy8319-Jun-12 9:04 
AnswerRe: Excel Chart in C# Pin
Eddy Vluggen19-Jun-12 9:19
professionalEddy Vluggen19-Jun-12 9:19 
GeneralRe: Excel Chart in C# Pin
Danzy8319-Jun-12 9:30
Danzy8319-Jun-12 9:30 
GeneralRe: Excel Chart in C# Pin
Eddy Vluggen19-Jun-12 10:00
professionalEddy Vluggen19-Jun-12 10:00 
GeneralRe: Excel Chart in C# Pin
Dave Kreskowiak19-Jun-12 11:06
mveDave Kreskowiak19-Jun-12 11:06 
AnswerRe: Excel Chart in C# Pin
Luc Pattyn19-Jun-12 11:21
sitebuilderLuc Pattyn19-Jun-12 11:21 
AnswerRe: Excel Chart in C# Pin
Cracked-Down19-Jun-12 19:53
Cracked-Down19-Jun-12 19:53 
Questionlinq for C# 2010 Pin
sc steinhayse19-Jun-12 8:12
sc steinhayse19-Jun-12 8:12 
QuestionGrab a screenshot and send it via http Pin
mupersan19-Jun-12 7:33
mupersan19-Jun-12 7:33 
AnswerRe: Grab a screenshot and send it via http Pin
Pete O'Hanlon19-Jun-12 7:44
mvePete O'Hanlon19-Jun-12 7:44 
AnswerRe: Grab a screenshot and send it via http Pin
Luc Pattyn19-Jun-12 8:04
sitebuilderLuc Pattyn19-Jun-12 8:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.