I am used to writing regular expressions that support multiple options to specify case sensitivity, white space ignoring, meaning of . etc... In C#, these options are specified with (?i), (?x) and (?s) respectively.
How can these modifiers be used with Visual Studio Code find functionality? I am getting an error
Invalid regular expression: Invalid group.
Example:
q.*?abc.*?q
will match <q>heheabchihi</q>, but not
<q>hehe
abchihi</q>
due to the . not matching all characters (\n is omitted). Adding (?s) fixes that in C# regex, but not in Visual Studio Code. What is the Visual Studio Code way of using regex options?
Updated answer
in my original answer, I have overseen the visual studio code requirement, and here I update my answer based on that.
I have made this regex to find the match in Visual Studio Code.
q.*?(.|\n)+?.q
This will find the following:

Tested also here https://regex101.com/r/f3vKcU/1
Inspired by this answer.
Hope that helps.
Original answer
You can do something simple as adding [^<>] in your regex.
So change this
q.*?abc.*?q
to
q.[^<>]*?abc.*?q
Will do the job.
Check it https://regex101.com/r/DWQ9ZP/1
I got the inspiration from this answer.
you could match any character or newline like this:
<q>[\s\S\n]*<\/q>
this would select everything inside the q tag until it is closed
i used [\s\S] to select every other character aside \n, it would translate to every whitespace-character and every non-whitespace-character
added note: since * is a quantifier for 0 or more, the ? becomes unnecessary
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With