Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Regular Expression Problem
Message
 
To
20/06/2012 13:49:23
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01546399
Message ID:
01546461
Views:
34
Yup, I'm stupid.

Thanks


>You're running the Regex against the word instead of the line. Try this:
>
private static string getKeyValue(ref string Line, string WordToFind)
>{
>	var retVal = string.Empty;
>
>	if (Line.Contains(WordToFind))
>	{
>		Regex r = new Regex(@"(?:(?'Key'\S+): (?'Value'(?:.(?!\s+\S+:))*))",
>						RegexOptions.RightToLeft |
>						RegexOptions.CultureInvariant |                                
>						RegexOptions.Compiled);
>
>		var matches = r.Matches(Line);
>
>		var wordMatch = matches.OfType<Match>().Where(match => match.Groups["Key"].Value == WordToFind);
>		if (wordMatch.Any())
>		{
>			retVal = wordMatch.First().Groups["Value"].Value;
>		}
>	}
>
>	return retVal;
>}
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Reply
Map
View

Click here to load this message in the networking platform