Live data from Hacker News

Learn RegEx step by step, from zero to advanced

regexlearn.com

101–110 of 114 posts

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

#101
post #67

Earlier quoted context omitted.

-> start_of_line -> literal('Flippers') -> literal(':') -> optional -> whitespace_char -> end -> remember -> multiple -> digit; I literally can’t parse this as a whole. /^Flippers:\s?(\d+)/ is so much more obvious compared to that utter nonsense.

Like most code, it's easier to write regex than to read it later. In my recent vim history: /(\([^()]\|\n\)*\n\([^()]\|\n\)*) This was from two days ago. I think I was searching a huge sheet of regex match groups for any having line breaks to join. In a month, I'm not even sure I would recognize that I had authored this.

not every solution has to be reusable

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

#102
The english copy of some of the learning examples is rough and complex, which takes away from the lessons.

An example from 21/55:

"To express at least a certain number of occurrences of a character, we write the end of the character at least how many times we want it to occur, with a comma , at the end, and inside curly braces {n, }. For example, indicate that the following letter e can occur at least 3 time."

It should read something like:

"To express a match of a minimum number of character occurrences, we use a comma after the number of occurrences, within the curly braces {n, }. In the following, try building a regex to match the letter e occurring a minimum of 3 times sequentially."

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

#103
cool site and idea, here's 3 site UI suggestions

there's a bug when entering text into the regex area which creates new padded elements show up which makes text on the page shift, e.g. https://i.imgur.com/AFBccIn.gif

the line height in the subtitle area could be increased so the text isn't so cramped ( https://i.imgur.com/HReADcS.png )

the background color of the entire page should be darker (or use some other solution) to make the looking text more distinct as code text. ( dark grey on dark blue doesn't really stand out https://i.imgur.com/8Nt9YNl.png )

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

#104

cool site and idea, here's 3 site UI suggestions there's a bug when entering text into the regex area which creates new padded elements show up which makes text on the page shift, e.g. https://i.imgur.com/AFBccIn.gif the line height in the subtitle area could be increased so the text isn't so cramped ( https://i.imgur.com/HReADcS.png ) the background color of the entire page should be darker (or use some other soluti…

It would also be nice to not have to scroll the page to click the next and previous links on each learning step (pixel 5, msedge browser). 100vh maybe?

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

#106
Regular expressions are one of the first things I remember being taught in my intro CS class that really broadened my perspective on programming. Probably helped that the main language being taught was Perl, and my previous programming experience was BASIC ... Expectations might have been set low. One of those tools that's often over-applied, but invaluable in so many other situations.

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

#109
post #99

I learn regex just before I need it. Every. Time. After 25 years, it just doesn't stick.

Try this. Worked for me. https://www.executeprogram.com/courses/regexes

That course looks great and I'm sure that at the end of if I will be absolutely rocking at regex. Then I won't use it for 4 months and need it for something and all but the basics will be gone. I'll essentially have to relearn it each time. I don't think it's the learning material that's the problem, I've even done interactive Jupyter training, there's something about Regex itself that just won't stick.

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

#110

I respect regex for being a widespread DSL that makes certain things very declarative. My problem with it (other than all the different flavors—that’s just history’s fault) is that you don’t tend to get integrated help/tool support for them. They are often just plain strings—how is e.g. Intellij supposed to spot them reliably and help you? It’s too bad if we have to copy and paste regex strings into websites in order…

> how is e.g. Intellij supposed to spot them reliably and help you

It depends on the language. JavaScript has a dedicated RegExp object. If you use the literal notation or constructor, you will always get IntelliJ support (unless you decide to use the constructor and extract the regex string for whatever reason). I _think_ you could also mark a standalone string variable with JSDoc to get IDE support, too.

Post reply on HN