Wie Sie bereits herausgefunden haben, ist (?i)
das Inline-Äquivalent von RegexOptions.IgnoreCase
.
Gerade FYI, es gibt ein paar Tricks, die Sie damit machen kann:
Regex:
a(?i)bc
Matches:
a # match the character 'a'
(?i) # enable case insensitive matching
b # match the character 'b' or 'B'
c # match the character 'c' or 'C'
Regex:
a(?i)b(?-i)c
Matches:
a # match the character 'a'
(?i) # enable case insensitive matching
b # match the character 'b' or 'B'
(?-i) # disable case insensitive matching
c # match the character 'c'
Regex:
a(?i:b)c
Matches:
a # match the character 'a'
(?i: # start non-capture group 1 and enable case insensitive matching
b # match the character 'b' or 'B'
) # end non-capture group 1
c # match the character 'c'
Und Sie können sogar Fahnen wie folgt kombinieren: a(?mi-s)bc
Bedeutung:
a # match the character 'a'
(?mi-s) # enable multi-line option, case insensitive matching and disable dot-all option
b # match the character 'b' or 'B'
c # match the character 'c' or 'C'
Wie kann ich dies ein hinzufügen Ausdruck wie folgt: public const String URL = @ "^ (? :(?: https? | ftp): \/\ /) (?: \ S + (? :: \ S *)? @)? (? :(?! (?: 10 | 127) (?: \. \ D {1,3}) {3}) (?! (?: 169 \ .254 | 192 \ .168) (?: \. \ D { 1,3}) {2}) (?! 172 \. (?: 1 [6-9] | 2 \ d | 3 [0-1]) (?: \. \ D {1,3}) { 2}) (?: [1-9] \ d?| 1 \ d \ d | 2 [01] \ d | 22 [0-3]) (?: \. (?: 1? \ D {1,2} | 2 [0-4] \ d | 25 [ 0-5])) {2} (?: \. (?: [1-9] \ d? | 1 \ d \ d | 2 [0-4] \ d | 25 [0-4])) | (?: (?: [az \ u00a1- \ uffff0-9] - *) * [az \ u00a1- \ uffff0-9] +) (?: \. (?: [az \ u00a1- \ uffff0-9] - *) * [az \ u00a1- \ uffff0-9] +) * (?: \. (?: [az \ u00a1- \ uffff] {2,})) \.?) (? :: \ d { 2,5})? (?: [/? #] \ S *)? $ "; – Yovav