Please suggest me regex pattern for the string like below: <[XYZ-ABC]>
I have to find these strings using Microsoft.Office.Interop.Word and then save the search string in database.
Thanks for any help provided.
Please suggest me regex pattern for the string like below: <[XYZ-ABC]>
I have to find these strings using Microsoft.Office.Interop.Word and then save the search string in database.
Thanks for any help provided.
Got one answer please let me know if its correct:
<[^/>]*>
Try this:
private Regex angleReg = new Regex(@"<([^>]+)>\s+<([^>]+)>");
private string[] parse(string rawInput)
{
    Match angleMatch = angleReg.Match(rawInput);
    if (angleMatch.Success)
    {
        return new string[] { angleMatch.Groups[1].Value, angleMatch.Groups[2].Value };
    }
    else
    {
        return null;
    }
}
In a .NET regex, the things like [^abcd] mean "anything not a, b, c or d" so in our case we want anything not ">". [^>]+ means "anything not >" "one or more times" which is what + is. So a+ matches "a", "aa", "aaa", etc. (x)(y) matches "xy" but then, in your Match object, the .Groups list will contain "x" at Groups[1] and "y" at Groups[2] for easy access to the matched strings.