I'm new to Regular Expressions and I have some questions in my codes.
I tried this but both return false
string pattern = @"\?!";
Console.WriteLine(Regex.IsMatch("!", pattern));
// false
Console.WriteLine(Regex.IsMatch("?", pattern));
// false
But when I did it this way both return true
string pattern = @"\!?";
Console.WriteLine(Regex.IsMatch("!", pattern));
// true
Console.WriteLine(Regex.IsMatch("?", pattern));
// true
So my question is.
- Is the order of
?
matters? - How does
?
work in Regular Expressions?