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.
You Should Learn Regex
21–30 of 57 posts
Re: You Should Learn Regex
#22It's useful to ensure you're not matching things that you don't mean to, which is a problem I often see when code reviewing regex.
Re: You Should Learn Regex
#23* `\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
#24Re: You Should Learn Regex
#25> From validating email addresses Guys, no. Send an email. https://davidcel.is/posts/stop-validating-email-addresses-wi...
Re: You Should Learn Regex
#26Re: You Should Learn Regex
#27Re: You Should Learn Regex
#28Earlier 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?
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
#29haven'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…