Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
“Some people, when confronted with a problem, think ‘I know, I'll use regular expressions.’ Now they have two problems.”
—Jamie Zawinski
Obligatory quote. But seriously, this is a classic use case for regex. Did you by chance find https://python.developpez.com/cours... in your searches? -
I hated Regex too when I was new to it, but now I actually like it.
It is especially useful for search and replace stuff if I want to replace some code but always keep some matching group in the middle. -
mszaf1856yAlso unless you have a very niche application for regex, just Google what your use case is with regex and someone most likely already made a viable one! No need to reinvent the wheel.
-
CptFox16166yProtip : to future-proof your regex, break it into blocks with a comment for their meaning, and then concatenate them (at compile time if you can).
Do I use this super handy technique on some of my own, 80+ chars long regex? HELL NO
ALL HAIL REGEX101 -
@Matt-Smeets yeah too bad. But Who the hell creates an account to just ++ a Rant and vanish !
-
ddephor44466yProblem with regex is that every implementation uses its own dialect. So switching between Perl, Python, Lua and Bash I always need the manual
-
donuts236726yhttps://regexr.com
I always use this if I get real stuck. Just keep trying to you get what you needed. -
@martygeek they practice the dark art of วฅษษแตฝ... ๐๐๐๐... ๐๐ฃ๐๐ก... ๐๐๐๐... gๅฐบไน๏ฝฑ... ๏ปฎะณัืง... γρεπ... โโกโโ....
Ironically, you’ll have a hell of a time matching the word “grep” in the above paragraph using a regular expression :D
Related Rants
Regex.
I HATE YOU.
There. I've said it.
I spent the better part of the last hour trying to wrangle together, not one, but TWO regexes and getting them to work with Python's "re" module.
The worst part about these little shits? It's how well they work once you figure out how to get them to work. For example, pulling a phone number out of a paragraph is difficult with string methods, but cake with regex . . . if you can figure out the pattern.
But I think I'll always have hate in my heart for Regex just for how obtuse and frustrating they can be.
F**k you regex.
rant
python
regex