Regex with wildcards in string and regex
Trying to do a match between two strings when both the strings have * wildcards. E.g. license plates witness 1 sees A*23* and withness 2 sees *123*Z. I want these to flag up as a match.
e.g. if I niavely do
string plate = "A.*23.*";
Regex r1 = new Regex(@".*3.*");
Console.WriteLine(r1.IsMatch(plate));
Regex r2 = new Regex(@"A123");
Console.WriteLine(r2.IsMatch(plate));
Regex r3 = new Regex(@".*Z");
Console.WriteLine(r3.IsMatch(plate));
Regex r4 = new Regex(@".*123.*Z.*");
Console.WriteLine(r4.IsMatch(plate));
then I get
true
false
false
false
whereas I want them all to be true. The problem is a bit more complex than this, but understanding how to deal with wildcard in the original string (not just the regex) would be a good start. Any ideas?