jjice 5 days ago

I really liked Mastering Regular Expressions by Jeffrey Friedl. He goes in depth on what they are (with a bit of FSA background) and how a regex engine works. It helps conceptualize what's going on and how to know what your specific regex library is doing.

Does that matter all that much? Not necessarily, but it's good to know things like whether or not your regex can blow in time complexity due to back tracking or not.

Other than that, there's a syntax overview that's very strong, and the rest is pretty straight forward from there - just applying sequential pieces one after the other to build your pattern.

I also like those regex crosswords - those are some of my favorite puzzles to do. I wish there were more of them! https://regexcrossword.com/

sandreas 5 days ago

A cheatsheet, stackoverflow and https://regex101.com/ - and of course a basic understanding of regular expressions in general.

If something gets too complex, I tend to write a Tokenizer / Lexer these days. It's not that hard.

  • cpach 3 days ago

    Out of curiosity, do you perhaps have some specific examples where you opted to write a tokenizer/lexer?

    • sandreas 3 days ago

      Most of the time when parsing whole formats, e.g. ffmetadata, cue or mp4chaps.

      Sometimes on complex rule based things or validation.

cpach 5 days ago

Perhaps I’m boring, but I generally prefer to keep them as simple as possible (^_^)

solardev 5 days ago

I used to spend a lot of time writing these by hand with reference pages and such. But these days ChatGpt is so good at coming up with them (and/or debugging them) I just use that instead. It's basically just another language it can easily translate to and from.