1673
you are viewing a single comment's thread
view the rest of the comments
[-] conditional_soup@lemm.ee 117 points 1 year ago* (last edited 1 year ago)

Regex

Edit: to everyone who responded, I use regex infrequently enough that the knowledge never really crystalizes. By the time I need it for this one thing again, I haven't touched it in like a year.

[-] 9point6@lemmy.world 41 points 1 year ago

You get used to it, I don't even see the code—I just see: group... pattern... read-ahead...

[-] kameecoding@lemmy.world 33 points 1 year ago

Most of regex is pretty basic and easy to learn, it's the look ahead and look behind that are the killers imo

[-] PoolloverNathan@programming.dev 12 points 1 year ago

(?=) for positive lookahead and (?!) for negative lookahead. Stick a < in the middle for lookbehind.

[-] Kissaki@programming.dev 13 points 1 year ago

You always forget regex syntax?

I've always found it simple to understand and remember. Even over many years and decades, I've never had issues reading or writing simple regex syntax (excluding the flags and shorthands) even after long regex breaks.

[-] Akito@lemmy.zip 16 points 1 year ago

It's not about the syntax itself, it's about which syntax to use. There are different ones and remembering which one is for which language is tough.

[-] Lehmanator@programming.dev 3 points 1 year ago

This is exactly it. Regex is super simple. The difficulty is maintaining a mental mapping between language/util <-> regex engine <-> engine syntax & character class names. It gets worse when utils also conditionally enable extended syntaxes with flags or options.

The hardest part is remembering whether you need to use \w or [:alnum:].

Way too few utils actually mention which syntax they use too. Most just say something accepts a "regular expression", which is totally ambiguous.

[-] PlexSheep@infosec.pub 2 points 1 year ago* (last edited 1 year ago)

I give you that, true. I wish vim had PCRE

[-] ewenak@jlai.lu 0 points 1 year ago

There is the "very magic" mode for vim regexes. It's not the exact PCRE syntax, but it's pretty close. You only need to add \v before the expression to use it. There is no permanent mode / option though. (I think you can remap the commands, like / to /\v)

[-] Lehmanator@programming.dev 1 points 1 year ago

This is exactly it. Regex is super simple. The difficulty is maintaining a mental mapping between language/util <-> regex engine <-> engine syntax & character class names. It gets worse when utils also conditionally enable extended syntaxes with flags or options.

The hardest part is remembering whether you need to use \w or [:alnum:].

Way too few utils actually mention which syntax they use too. Most just say something accepts a "regular expression", which is totally ambiguous.

[-] Lehmanator@programming.dev 1 points 1 year ago

This is exactly it. Regex is super simple. The difficulty is maintaining a mental mapping between language/util <-> regex engine <-> engine syntax & character class names. It gets worse when utils also conditionally enable extended syntaxes with flags or options.

The hardest part is remembering whether you need to use \w or [:alnum:].

Way too few utils actually mention which syntax they use too. Most just say something accepts a "regular expression", which is totally ambiguous.

[-] Lehmanator@programming.dev 1 points 1 year ago

This is exactly it. Regex is super simple. The difficulty is maintaining a mental mapping between language/util <-> regex engine <-> engine syntax & character class names. It gets worse when utils also conditionally enable extended syntaxes with flags or options.

The hardest part is remembering whether you need to use \w or [:alnum:].

Way too few utils actually mention which syntax they use too. Most just say something accepts a "regular expression", which is totally ambiguous.

[-] _stranger_@lemmy.world 8 points 1 year ago

https://regex101.com/

Don't let the gatekeepers keep you out. This site helps.

[-] activ8r@sh.itjust.works 1 points 1 year ago

Nice! This is the one I use: https://regexr.com/
Though it appears to be very similar on the face of it.

[-] PlexSheep@infosec.pub 4 points 1 year ago

No. Learn it properly once and you're good. Also it's super handy in vim.

[-] SwordInStone@lemmy.world 0 points 1 year ago

interns gonna intern

This is one of the best uses for LLM’s imo. They do all my regex for me.

[-] dirtycrow@programming.dev 1 points 1 year ago

For me I spent one hour of ADHD hyper focusing to get the gist of regex. Python.org has good documentation. It’s been like 2 years so I’ve forgotten it too lol.

[-] LeninOnAPrayer@lemm.ee 1 points 1 year ago* (last edited 1 year ago)

I just use the regex101 site. I don't need anything too complicated ever. Has all the common syntax and shows matches as you type. Supports the different languages and globals.

this post was submitted on 05 Mar 2025
1673 points (98.9% liked)

Programmer Humor

30365 readers
1528 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS