Regex to extract a string between two delimeters WITHOUT also returning the delimeters?
- by CSharp Noob
Hello,
I want to just extract the text between the brackets -- NOT the brackets, too!
My code looks currently like this:
var source = "Harley, J. Jesse Dead Game (2009) [Guard]"
// Extract role with regex
m = Regex.Match(source, @"[(.*)]");
var role = m.Groups[0].Value;
// role is now "[Guard]"
role = role.Substring(1, role.Length-2);
// role is now "Guard"
Can you help me to simplify this to just a single regex, instead of the regex, then the substring?