RegEx resources

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

  1. 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.
  2. RegEx LAB If you have an iPhone or iPad, this app is for you. - @PaulWatts
  3. A great cheatsheet-ish tutorial is here. - @pottster
  4. If you are familiar with programing this page is a great resource. @jeanluc
  5. A great podcast episode by automators podcast. Trying their best to teach RegEx. - @Stan
  6. 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

  1. 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
  2. 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
28 Likes

This video goes over RegEx including some examples on how to use it in Obsidian:

6 Likes

Awesome! Is it your channel?

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

6 Likes

Nice video! Liked and subscribed. When I have the time I’m going to watch the rest. Thanks for the work you’re doing :grin:

2 Likes

Thanks a lot! and I agree, It is a huge update!

2 Likes

@aakaash Thanks for these videos, there well done; very helpful!

3 Likes

Hello, another regex sandbox (with a regex visualizer): https://extendsclass.com/regex-tester.html

1 Like

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.

3 Likes

I will be glad if other obsidian users can also share similar ReGex cheats, which might benefit a lot of users including me.

Thanks

1 Like

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.

1 Like

Short version -

In the search box, put the regular expression between leading and trailing “/” 's, similar to Perl. /(regular expression)/