C# RegEx: Ignore case… in pattern?

前端 未结 1 965
清歌不尽
清歌不尽 2020-12-04 23:20

I\'m using System.Text.RegularExpressions.Regex.IsMatch(testString, regexPattern) to do some searches in strings.

Is there a way to specify in the regexPattern stri

相关标签:
1条回答
  • 2020-12-05 00:01

    (?i) within the pattern begins case-insensitive matching, (?-i) ends it. That is,

    (?i)foo(?-i)bar
    

    matches FOObar but not fooBAR.

    EDIT: I should have said (?-i) starts case-sensitive matching - if you want the whole pattern to be case-insensitive then you don't need to "end" the (?i).

    0 讨论(0)
提交回复
热议问题