I would like to use the equivalent of:
\<FooterTemplate.+?\<\/FooterTemplate\>/gms
In a Find and Replace regex for html/asp tags and their contents in visual studio 2015.
The above regex will not work in VS, but does in regex101.
The closest I got with VS syntax was something like:
\</*FooterTemplate[ ]*.*\>
but only matches outside tags:
How can I edit the above regex to include contents in between the tag when searching?
Vscode has a nice feature when using the search tool, it can search using regular expressions. You can click cmd+f (on a Mac, or ctrl+f on windows) to open the search tool, and then click cmd+option+r to enable regex search. Using this, you can find duplicate consecutive words easily in any document.
Visual Studio uses . NET regular expressions to find and replace text.
You can select a whole tag in VS Code by using the balance inward and balance outward Emmet commands. It's helpful to bind these commands to keyboard shortcuts, like Ctrl + Shift + Up Arrow for Balance Outward and Ctrl + Shift + Down Arrow for Balance Inward.
VSCode is using JavaScript-based regex engine, but it is not the same. You cannot use named capturing groups there. There is no specific documentation on the regex used in VSCode. However, if you have a look at the source code, you will see lots of JS code around.
In VS search and replace tool, you can use [\r\s\S]
character class to match any text spanning across multiple lines.
To match as few characters as possible to get a valid match, you need to use *?
or +?
lazy quantifier.
So, you can use
<FooterTemplate[\r\s\S]+?</FooterTemplate>
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