Email or username:

Password:

Forgot your password?
Top-level
Ivory by Tapbots :emoji_wink:

Regular Expressions allow you to filter your posts in powerful ways. A good place to test new expressions to make sure they work properly is at regex101.com

Have fun!

Screenshot showing a regex test case on the site regex101.com
38 comments
Jens

@ivory You might want to rather use \b instead of (space), so you're also able to match hashtags and other non-alpha-numeric chars.

Cedr\c :ivory_logo:

@ivory @daskaja How to include capital letters? "Elon" is not counted

Jens

@cedric @ivory \b[Ee][Ll][Oo][Nn]\b - not nice, but works

Jakub

@daskaja @cedric @ivory
To ignore case sensitive type:

(?i)\belon\b

xinit ☕

@cedric

Yeah, a /i would be a help, for sure. Maybe [Ee]lon would work? I don't subscribe, and regex is one of the sub-only features.

On a tangent, wouldn't it be nice to have search/replace option in addition to basic filtering? Imagine /elon/shitbird/gi as a global filter, @ivory @daskaja

[aware event]

@xinit @cedric @ivory @daskaja Try

(?i)\belon\b

But yeah, it should probably be in the UI.

xinit ☕

@Wevah

I'm out of regex practice, but the (?i) checks out on regex101.com

@cedric @ivory @daskaja

burgatshow

@daskaja @ivory also a /i flag to make it case insensitive. ;)

Jens

@burgatshow @ivory I wasn't sure if modifiers were supported here, since the GUI is a bit misleading. But if so, better use /i

burgatshow

@daskaja @ivory sure. You are right. It is more like a suggestion to @ivory to implement the switch for case sensitivity.

Aaron Mahler

@daskaja @ivory Seemed a good test question to pose to ChatGPT - which resulted in precisely your same \b recommendation along with a decent description of the reasoning. I did that before seeing your reply, so not saying it validated your answer - more the other way around. :)

Ryan Booker

@daskaja @ivory I think they're also case sensitive (at least they were?) so all mine are prefixed with (?i)…

dxzdb

@daskaja @ivory omg - am I finally going to have to learn regex because of a mastodon app! 😵🤣

Paul

@ivory Like the topic you‘ve chosen for your example regex… 🤫

James Gilbert

@ivory One of my favourite sites is RegExper, which visualises regular expressions. Useful if they are more complex.
regexper.com/#%5Cbelon%5Cb

Mark Boszko

@ivory which flavor should we pick in the left column to match how Ivory will interpret the regex?

Ivory by Tapbots :emoji_wink:

@swizzlevixen For basic pattern matching, I didn't change the flavor. I am not a regex expert. Just wanted to provide a basic solution to a very common problem people have with keyword filters. 🙂 If you want to know more about what we use, you can go here: unicode-org.github.io/icu/user

Jon Michaels

@ivory This is AWESOME! Thank you!

I would strongly recommend Chapter 8 of the BBEdit Manual for anyone who wants to learn more about Regular Expressions. It's my go-to whenever I need help with a tricky pattern match.

I believe we have @gruber to thank for that one.

It is available here:

barebones.com/support/bbedit/m

Lady Di

@ivory 🙂 That topic example choice! 👍🏻💕

Kevin Riggle

@ivory oh ffs you couldn’t just wrap the keywords in ‘\b…\b’ like everyone else does and all your users expect from decades of Google and other full-text search engines

Sascha

@ivory Regex and Fun in one sentence… 🤣

Martin the paranoid android

@ivory \byouknowwho\b gets initial Youknowwho and when punctuation follows.

Tim from the Island💫♥️🇮🇲

@ivory As someone who has been a software developer for over 30 years, I can definitely state that regexes are the work of satan

Matt W

@ivory You can also ask ChatGPT, it’s great at generating regex!

Kerim Friedman 傅可恩

@ivory I've actually found that ChatGPT is really useful for writing RegEx when I can't figure it out myself.

Go Up