How to add multiple options in RegexOptions


I need to check RegexOptions.Singleline RegexOptions.IgnoreCase both while extracting a text from a string. For this I have created a variable (of type RegexOptions) and added Assign like below

RegOptions = RegexOptions.Singleline

But I need to add RegexOptions.IgnoreCase as well in RegOptions.
Based on c# pattern I tried to add it like below

RegOptions = RegexOptions.Singleline | RegOptions = RegexOptions.IgnoreCase

and also
RegOptions = RegexOptions.Singleline And RegOptions = RegexOptions.IgnoreCase

and even with another Assign

RegOptions = RegexOptions.Singleline

But none of this is working.

Please help.



Do you use VB mode? If so the following sample helps you. (Please use OR operator)

System.Text.RegularExpressions.Regex.Match(s,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase OR System.Text.RegularExpressions.RegexOptions.Multiline ).Value



Thanks it worked.

Another question, I want to replace System.Environment.Newline with space, as desired output contains multiple lines, using like below (where Matched is the matched string)

Matched.ToString.Trim.Replace(system.Environment.NewLine," ")

But this is not producing desired results, any inputs in this.



If there is a possibility to exist unix style line break, can you try the following?

Matched.ToString.Trim.Replace(vbCrLf," ").Replace(vbLf," ")


1 Like

Thanks a lot for your support, it is working.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.