Earlier quoted context omitted.
Even that is wrong because you can have privately owned TLDs (I forget what they're technically called) like .google So sundar.pichai@google is technically a valid address (whether .google has any MX records is another matter) Regex shouldn't really be used for email addresses anyway because the only reliable way to authenticate an email address is to literally send an email to that address.
AFAIK none of the TLDs allow for MX records on just the TLD i.e. johndoe@com will never exist
Show HN: Regex Cheatsheet
121–130 of 135 posts
Re: Show HN: Regex Cheatsheet
#122Re: Show HN: Regex Cheatsheet
#123Re: Show HN: Regex Cheatsheet
#124Would be nice to have a regex for parsing HTML... grabs popcorn
boom. https://regex101.com/r/PxSY4U/1 technically it does parse it. :P
Re: Show HN: Regex Cheatsheet
#125Earlier quoted context omitted.
RE2 syntax[1] is a pretty good option to learn, because it's mostly a "lowest common denominator" - if it works in RE2, it should work in PCRE, Python, Javascript, etc. The reverse isn't true - there is a bunch of syntax that RE2 doesn't support by design, often to constrain performance bounds. Emacs regexps are unfortunately their own weird beast - they handle parentheses differently than other regexp engines, becau…
IME Emacs provides a very pleasant way to write regexps using the rx library. ELPA also has the package xr, which converts Elisp regexps to rx format, and pcre2el converts PCRE to Elisp. So a regexp like \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b Can easily be converted like: (->> "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\\b" pcre-to-elisp xr) To: (seq word-boundary (one-or-more (any "0-9A-Z" "%+._-")) "@" (one-or-m…
Re: Show HN: Regex Cheatsheet
#126Re: Show HN: Regex Cheatsheet
#127Earlier quoted context omitted.
> Honestly, as a noob, this is one of the biggest reasons I have such a hard time deciding to learn regex. Clear your afternoon, and just learn it. Seriously, it takes a couple of hours at best and then - BOOM - you're done for the rest of your life.
> you're done for the rest of your life. If that were so easy then I don't think much of these cheatsheets would exist.
Re: Show HN: Regex Cheatsheet
#128One thing i've always missed from the Perl programming language is the regex operators. You could do: my $var='foo foo bar and more bar foo!!!'; if($var=~/(foo|bar)/g){ # does the variable contain foo or bar? print "foo! $1 removing foo..\n"; # remove our value.. $var=~s/$1//g; }
So did I: https://github.com/radiac/python-perl/
Re: Show HN: Regex Cheatsheet
#129OK, these kinds of regex tools get posted quite often. I get it, regex is very confusing at first. And some of these use-cases result in rather complex expressions nobody should be forced to write from scratch (you are still remembering to write unit tests for them though, right?) But as someone who actually knows [some flavours of] regex fairly well, what I would really like, is a reference that covers all the subtl…
The O’Riley book “mastering regular expressions” has a whole section dedicated to it. As well as several tables. But it would be nice to have an online version.
Re: Show HN: Regex Cheatsheet
#130This is awesome but.... I don't hate regex. Matter of fact, I love regex.
check out the ipv6 one :)
¯\_(ツ)_/¯