Reputation:
I have this code
Regex.Match(contents, @"Security=(?<Security>\D+)").Groups["Security"].Value;
this makes the following:
Security=SSPI;Database=Datab_ob
How do I make the Regex cut off at ; so i would only get Security=SSPI
Upvotes: 1
Views: 97
Reputation: 32936
you could to use a positive lookahead to look for the ; after your string, but not to match it. Using this:
Security=(?<Security>\w+(?=;))
as the regex pattern will get any words after the '=' and before the ';' into the Security named group
Upvotes: 0
Reputation: 4410
Regex.Match(contents, "Security=(?<Security>[^;]+)").Groups["Security"].Value
Upvotes: 3