I'm having trouble finding a clear tutorial on how to use regular expressions, and its driving me insane..
However, based on an example I saw, I am trying to construct my own pattern and I cannot figure out why it is not working. Can somebody here give me some help?
I have a string that begins with "Data Source=" and I want to parse the data that comes after the = and before the ; at the end. But I also want to split the string into a path/filename pair (so I can store them in separate variables)
The code I have is as follows, but doesn't match anything.
string data = @"data source=c:\blah\file.ext;some more options=...;"; string regex = @"data source=(^.*\\)([A-Za-z0-9\-]+\.[A-Za-z0-9]+)$"; Match asdf = Regex.Match(data, regex, RegexOptions.IgnoreCase); Console.WriteLine(asdf.Groups.Value); Console.WriteLine(asdf.Groups.Value);