Reputation: 1284
What am I doing wrong here? .Net supports the (?i:) construct for inline modification of case sensitivity ... but I can't get this line to work.
Console.WriteLine(Regex.Match("ab(?i:z)", "abZ").Success); //Returns false,
//though it should return true??
Upvotes: 1
Views: 149
Reputation: 172448
The signature for Regex.Match is
public static Match Match(
string input,
string pattern
)
So, Regex.Match("abZ", "ab(?i:z)")
will do what you want.
Upvotes: 3
Reputation: 120518
How about getting the parameters in the correct order?
Regex.Match("abZ", "ab(?i:z)").Success
Upvotes: 2
Reputation: 700730
The first parameter is the input, the second parameter is the pattern:
Regex.Match("abZ", "ab(?i:z)")
MSDN: Regex.Match(string, string)
Upvotes: 6