Regex Isn't Hard
timkellogg.me
timkellogg.me
I think the actual advice is fine, BTW. Tools like regex101.com and now LLMs are super-handy for reading and writing regex as well.
So with the help of an iOS app called “Redirect Web”, and a clever regex written mostly by ChatGPT, I now have my nice i.reddit.com experience back
i don't particularly like the way the article is presented on technical grounds. it should stick the real basics ., * first.
but no, regex is an extremely simple language and a basic underpinning of computer science. if it's "too hard", you've either been taught wrong or have no business writing code of any other sort.
agree on props to regex101 and other similar sites.
So in general I would classify the article into the "marketing text" category: not completely false but not telling the truth ;-)
[^ab] means “everything but a or b
...
. — The dot (.) matches any character, but not always. Sometimes it doesn’t match newlines. In some programming languages it never matches newlines. I’ve gotten bitten too often by the . not behaving like I think it should. It’s best to ignore this entirely
Is the negation class somehow more standardized than the `.`? I mean, if you do [^X] it's typically going to match any character that isn't X except character returns and line feeds. `.` works the same way, except it will also match X. And for what it's worth, I can't think of the last time I ran into it somewhere that it also matched newlinesThe TL;DR is, RegEx behaves slightly differently in each programming language. For example, if and how newlines are matched.
There are three main flavors of RegEx: POSIX, Extended, and PCRE. Most UNIX tools implement either POSIX or Extended. Most Programming languages implement PCRE. Some programs (/cough vim/) just make up their own regex langauge as they go.
[1] https://stackoverflow.com/questions/159118/how-do-i-match-an...
Because the article recommends using a capture group negation to match a character when you know a specific character or set of characters won't be in the group, but doesn't mention why capture groups (and negations) are acceptable to use, while the `.` should be avoided ("because it might have this less predictable behaviour that I'm totally going to avoid talking about with capture group negations")
mmh-hn-trt@xn0.org
is there one too many close brackets ] in there there?
Regex everywhere isn't what makes Perl hard to read IMHO.