I would like to know why, with the following input, the function IsMatches returns false.
What is the problem with my pattern. Thanks a lot.
var input = @"/****** Object: Table [etc_abc] Script Date: 11/27/2012 13:24:26 ******/";
public bool IsMatched(string input)
{
var match = Regex.Match(input, @"/\*+\sObject:\s+Table\s+[\[[a-zA-Z0-9_\\]+\]\.]??(\[[a-zA-Z0-9_\\]+\])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
return match.Success;
}
I don’t know about C# regex in particular, but this part looks suspicious:
[\[[a-zA-Z0-9_\\]+\]\.]??.You don’t want to treat this as a character class, you probably want to treat it as a group, so use simple parentheses instead of square brackets:
(\[[a-zA-Z0-9_\\]+\]\.)??So this might work for you:
@"/\*+\sObject:\s+Table\s+(\[[a-zA-Z0-9_\\]+\]\.)??(\[[a-zA-Z0-9_\\]+\])"