I would like to configure a RexEx to match any folder (parent or child) of a file path of any open file. So if any folder in the file path contains the name of the open file, the color coding of the tab is set based on the RegEx match.
For example: websiteRoot/Content/MyName1/site.css = green colored tab when file opened
websiteRoot/Content/MyName2/site.css = orange colored tab when file opened
websiste/Shared/MasterPages/MyName1/main.master = green colored tab when file opened
websiste/Shared/MasterPages/MyName2/main.master = orange colored tab when file opened
I have tried:
.*MyName1?$
but this is only looking at the file name I believe.
Also tried .*//MyName1//?$
and I thought this next one would do the trick if Regex for this extension directly matches on the open file path: ^.*\\MyName1
More promising regex with no success:
.*websiteRootPath.*MyName1|myname1|myName1
And if Power Productivity Tools works off a relative path for the open file:
.*MyName1|myname1|myName1
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.
We can use the JavaScript string instance's match method to search for a string that matches the given pattern. to call match with a regex that matches the exact word. ^ is the delimiter for the start of the word. And $ is the delimiter for the end of the word.
To use regular expressions, open either the Find pane or the Replace pane and select the Use check box. When you next click Find Next, the search string is evaluated as a regular expression. When a regular expression contains characters, it usually means that the text being searched must match those characters.
VS Code does support regular expression searches, however, backreferences and lookaround aren't supported by default. But you can enable these with the setting search. usePCRE2. This configures ripgrep to use the PCRE2 regex engine.
I was working on this in VS 2017, you have to enable the option to match the path of the document.
You need to have some background about regular expressions, here are some examples:
.*folder\\.*$
.*folder\.detail\\subfolder\\.*$
.*folder\\subfolder\\subfolder\\.*$
You can test your own regex here
You have to check "Use full document path for regular expression matching" under
Options -> Productivity Power Tools -> Advanced
After that, you can use the RegEx's like
.*app\\model\\.*$
.*app\\view\\.*$
.*app\\controller\\.*$
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