I’m wondering if the following is possible:
The method Regex.Match can receive an enum, so I can specify:
RegexOptions.IgnoreCase
RegexOptions.IgnorePatternWhiteSpace
RegexOptions.Multiline
What if I need to specify more than just one? (eg. I want my regex to be Multiline and I want it to ignore the pattern whitespace).
Could I use | operator like in C/C++?
You need to annotate it with
[Flags]attribute and use|operator to combine them.In the case you mentioned, you can do that because
RegexOptionsenum is annotated with it.More References:
A helpful way to use the FlagsAttribute with enumerations
Example Snippet from above CodeProject article:
Definition:
Use: