Live data from Hacker News

You Should Learn Regex

blog.patricktriest.com

21–30 of 57 posts

Re: You Should Learn Regex

#21
post #11

When I used to code in Perl (more than ten years ago) I tended to solve many many things using regexes. I tried to reduce many programming challenges into transformations that I could do via regexes. Why? Because regular expressions are first class citizens in Perl. And Perl made me learn and use them. (Reminds me of a an APL programmer that saw vectors everywhere.) When I replaced Perl with Python in my toolbox I ab…

I found the same thing. When I was writing Perl half the point was using regex. I inherited a site about 5 years ago that was a huge Perl site built entirely on text files and regex. The developer had basically built a database out of text files. He had directories for indexes, associations, etc. It wasn't pretty to look at but it was still to this day the fastest site I've ever worked on.

How did he achieve transactionality?

Re: You Should Learn Regex

#23
haven't read/processed the article fully, some nitpicks:

* `\b([01]?[0-9]|2[0-3]):([0-5]\d)\b` you are using both [0-9] and \d, is that intentional?

* `cat test.txt | grep -E "^[0-9]+$"` UUoC and double quotes subjected to shell interpretation, should be `grep -E '^[0-9]+$' test.txt` or `grep -xE '[0-9]+' test.txt`

* `(?i)` won't work with `grep -E` (or at least not for me on GNU grep). features of BRE/ERE and PCRE like regex are very different - see https://unix.stackexchange.com/questions/119905/why-does-my-...

* avoid parsing ls - https://unix.stackexchange.com/questions/128985/why-not-pars... , use glob/find

* `.?` again, this regex feature is not available with BRE/ERE, your example just happens to work. you can check it with `echo 'abc foo 123 bar 123' | perl -pe 's/foo.?123//'` and `echo 'abc foo 123 bar 123' | sed -E 's/foo.?123//'` (using to avoid formatting issues)

Re: You Should Learn Regex

#25

> From validating email addresses Guys, no. Send an email. https://davidcel.is/posts/stop-validating-email-addresses-wi...

The article you link to addresses just the one use case where you are registering a new user. Email addresses in business applications are just as often NOT the address of your user. Sales contacts, managers, points of contact, customer support addresses, etc. -- none of these should ever be validated by sending an e-mail. So you still need to validate the hard way in plenty of scenarios.

Re: You Should Learn Regex

#28
post #21

Earlier quoted context omitted.

I found the same thing. When I was writing Perl half the point was using regex. I inherited a site about 5 years ago that was a huge Perl site built entirely on text files and regex. The developer had basically built a database out of text files. He had directories for indexes, associations, etc. It wasn't pretty to look at but it was still to this day the fastest site I've ever worked on.

How did he achieve transactionality?

Anywhere that he'd need transaction safety in the system, everything was contained in a single file.

There were other jobs that could rebuild indexes by scan, repair associations or break things down into parts of use on other areas of the site but the areas that needed safety were lumped together as a single record (similar to the NoSQL approach honestly).

It wasn't a general purpose setup, but it worked for his purposes.

Re: You Should Learn Regex

#29
post #23

haven't read/processed the article fully, some nitpicks: * `\b([01]?[0-9]|2[0-3]):([0-5]\d)\b` you are using both [0-9] and \d, is that intentional? * `cat test.txt | grep -E "^[0-9]+$"` UUoC and double quotes subjected to shell interpretation, should be `grep -E '^[0-9]+$' test.txt` or `grep -xE '[0-9]+' test.txt` * `(?i)` won't work with `grep -E` (or at least not for me on GNU grep). features of BRE/ERE and PCRE l…

Thanks, that's all very useful feedback.
Post reply on HN