Regular Expressions (RegEx) are a coding convention used in many different contexts and coding languages, which are great for finding and replacing words and strings of characters.
Since version 0.8.0, Obsidian has added support for using regular expressions in search (and hopefully will add replace function as well).
Earlier in another topic, I asked for the best ways to learn RegEx, and many answers came up. I will add them all here along with any other RegEx related resources. If you have any more suggestions, please feel free to reply to this topic, and I will do my best to update this first post.
Learning resources
Awesome video about the new search functions and its uses in Obsidian by our very own @aakaash. (update: @aakaash added another video covering the new syntax here.
Regexone - This is a great web-based interactive way of learning RegEx. I particularly enjoyed it, and I would highly suggest it to those without any coding background. @danbburg
Sandboxes
This is a Sandbox great for playing around with complex regex before using it. It is especially useful for destructive “replace” operations before using it. it is especially helpful for destructive “replace” operations. @danbburg
regex101 is another excellent sandbox. Which also may help the process of learning it as well. It has different flavors of RegEx. You should choose ECMAScript (JavaScript), which is what Obsidian is using. - @Silver
Yes ! Just uploaded a new video to go over the new changes to using regular expressions in search as well as addition of anchors and other notable changes
in case anyone of you want to see all your empty md files in the vault, you can use this simple regex search
content:-/.*/ in the search bar.
explanation: .* looks for any character in a file /.*/ this is the same thing enclosed in / / for regex syntax - in front of the whole expression means inversion; which in layman terms means to get all the files without any characters (or the empty files). content: looks for only the contents inside the files and not the filenames.
Great topic. For Mac users with a Setapp subscription, I recommend TextSoap and Expressions. Or you can buy one or both directly from the devs at the links above.
In TextSoap you can test live searches and it will highlight the results before you commit, or you can step through one change at a time. It’s also very good at automatically opening whatever you have in your clipboard, then letting you copy and paste everything in the sandbox back into Obsidian. You can save your most-used expressions or choose from a library of pre-existing ones, or use the GUI and build your own. (I have no affiliation, just an avid user.)
In Expressions you have a good reference library and it also gives live testing. It’s just not as robust as a stand-alone editor. It is cheaper to buy individually though.