Support for regular expressions (regex) in search

Sure would be nice if the Search in Bear support regex…

3 Likes

Hello!

I wrote most of Bear’s search engine and I personally always look for ways to expand what search can do. However, to me regexes seem to be an overkill for Bear, do you mind sharing what do you plan to use them for (use case scenario)?

Thanks

Hi back!

Importantly, I posted my comment about regex before I found the Bear FAQ showing search options.
I suppose if it was a royal pain to add this functionality it is more trouble than it is worth, given the existing search functionality — but it sure would be nice, as regex would allow for so much more. See the list [that was fun to write] below.

  • every occurrence of the phone number 103-555-1212 regardless of how it is formatted
  • a name regardless whether it’s spelled kierkeged, keirkeged, kierkegad, or keirkegad
  • the name “Adam” but only when it’s on the same line with “Eve”
  • all occurrences of the word “Balance” on the same line with a negative number greater than two digits
  • all places where “Balance” occurs with a number longer than 5 digits that might or might not contain a comma
  • all places where “Birth year” occurs next to a number in the range 1950 to 1980
  • all places where “Birthday” occurs next to “Feb 6,” “February 6,” or “2/6”
  • all occurrences of iso codes for US languges like US-CA, US-UK, etc. next to the word “no”
  • all domain names starting with “ftp.” and ending with “.uk”
  • all domain names that do not have a subdomain
  • all words in a list where the word contains non-latin characters
  • all words in a list where the word is spelled only using certain letters in any order
  • all occurrences of “Perry Mason sXeY” where X is 3, 4, or 5
4 Likes

I would love also to have this regex functionality.

Most often I copy from different sources and when I paste it in there are many of empty lines and go and remove them manually it’s a lot of work.

I wish to be able to detect all empty lines and remove them in one go.

As a programmer, I sometimes miss having regex search. I also understand that for Bear it might be overkill most of the time.

That said, I do miss it occasionally, especially combined with Search & Replace. For example, when I paste content from a webpage, I often get recurring formatting issues, like ordered lists missing the space after the dot (1.First item), which isn’t valid Markdown list syntax. Regex would make it easy to fix these patterns quickly across a note, without needing to paste it to VS Code and back to Bear.

1 Like