<10> My Fixation
Applications
For 7 months I was trying to write a blog about fix
And I think everyone would be fascinated by fix if I am able to peel the first layer of this mystery. Of course, in a way a younger and ignorant me would understand
<< I hate regex
Regular expressions suck. I mean look at this regex. (using python regex because every language has their own rules)
r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
This is for validating email addresses. But anyone would read past it thinking "some weird regex filter I can look back later"
<< Breakdown
These are just filters and these filters can be broken down into :
1. ^[a-zA-Z0-9_.+-]+ : check if character
1.1 a letter ('a-z') or ('A-Z')
1.2 a number ('0-9') or
1.3 an underscore ('_') or
1.4 a dot ('.') or
1.5 a plus ('+') or
1.6 a hyphen ('-')
There is also a caret symbol before the first pattern filter which might usually indicate NOT in multiple regexes but in case of python regex it means start of the first line
2. @[a-zA-Z0-9-]+ : This is can be interpreted similarly using the definitions above. `@<email provider>` using the bounds of letters and digits.
3. \.[a-zA-Z0-9-.] : Resembles TLD of the <email provider>
5. $: for the end of string ie. no more patterns to match
Edits
1. This post was updated on 17th October, 2025 on Friday. Replacing JS regex with python one. Because that required more explanation and the python one is easier although incomplete in its constraints.
2. I've also kept the tangential thoughts from previous iterations as it is. It is for me.
3. I added regex101's link here
|> Tangential Thoughts
a. yes [\w] are just terse ways of expressing [A-Z][a-z][0-9]_ filter
b. [...] and (...) are different
b.0 anything enclosed in [ ... patterns ... ] is just a way validating a character that matches the pattern
b.1 anything enclosed in ( ... patterns ... ) is just a way to capture characters.
An example.
- [abc]+ : matches for either a, b, or c
|cababcab| : would match the complete string
- (abc)+ : captures a continuous batch of abc strings
cab|abc|ab : in this case would match on a subset which is
a contiguous abc string
c. [...]+ the + implies "at least one" instance of pattern matches. If there are 0 instances then it is an invalid string.
d. TL;DR of non-greedy can be explained by the following example
e. How are greedy and non-greedy different
greedy
- /<.*>/ will match <foo> <bar> new </bar> </foo>
- /<.*?>/ will match <foo>
I don't know about you dear reader but this to me looks way too much for very little convenience. I don't deny it's convenience but if you like regex you would love APLs I'm assuming.
So this is the reason I hate regex.