Live data from Hacker News

Learn RegEx step by step, from zero to advanced

regexlearn.com

111–114 of 114 posts

Re: Learn RegEx step by step, from zero to advanced

#111
post #96
post #55

Earlier quoted context omitted.

Ignoring the flame bait, for me the only things I wish more regex engines supported (cough JavaScript) is the ability to ignore whitespace, and have named groups. Python has a flag to do this, and being able to have multi-line regexes with comments and named groups is phenomenal and greatly improves readability of more complex regexes. In general I would say ~70% of regexes are highly readable. With tools like the ab…

> Ignoring the flame bait, for me the only things I wish more regex engines supported (cough JavaScript) is the ability to ignore whitespace, and have named groups. Irregex? http://synthcode.com/scheme/irregex/

Interesting! I don't think that's what I mean. I don't think I want it to be a part of the language like that, but that's a pretty neat idea. For example, python has an 'X' flag you can use when creating a regex to allow new lines and comments. Here's an example from my code: https://github.com/internetarchive/openlibrary/blob/1ac15a48...

Re: Learn RegEx step by step, from zero to advanced

#112

I don't remember why, but I learned regexes maybe my sophomore year of college because it seemed like such an interesting thing that I might need some day? I also started to learn SQL about the same time. Those feel like herculean efforts so foreign now because I've been using them for so long. One day at my second job out of college, I wrote a quick regex for something, and one of my more senior colleagues looked at…

https://sat-smt.codes/SAT_SMT_by_example.pdf

Re: Learn RegEx step by step, from zero to advanced

#114
To my taste, there are no problems with regular expressions at all.

But there are problems in all sorts of escaping. Without peeking into Stack Overflow, can you tell, how to escape properly in grep/sed? If it is running in bash/zsh? In cygwin? In your favorite text editor? In bash/zsh script? How many slashes would you need for an opening bracket? For a pipe?

You just never know. This frustrates heavily.

I don't even try to use sed or grep. Instead, I just write a small Python or Racket script to do the job. This is what I recommend. While learning Regular Expressions, just stick to your favorite programming language with RE support. Like Python or Perl. Use it for everything you need.

Then abide to a heavy burden of escaping in all sorts of exotic environments.

Post reply on HN