Live data from Hacker News

Show HN: RegEx for Regular Folk – A visual, example-based introduction

refrf.shreyasminocha.me

101–110 of 113 posts

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#101
post #59

Nice intro. Tangential question. Is there a regex tool that shows where the expression failed ? Not in syntax, but the logical failure point? Would be useful for when an expression gets a little long and nested and modifications need to be made. Edit: I mean like: Target text is abcde Regex is /abe/ Is there a tool that will tell me it matched a and b and then failed trying to match e ? Those sites are great resource…

You want a debugger.

http://p3rl.org/rxrx

rxrx -e'"abcde" =~ /abe/'

Demo: https://blog-cloudflare-com-assets.storage.googleapis.com/20...

http://p3rl.org/re#'debug'-mode

perl -Mre=debug -e'"abcde" =~ /abe/'

----

https://stackoverflow.com/questions/2348694/how-do-you-debug...

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#102

Hi, very nice RegEx educational site/book. Feedback: - In the chapter https://refrf.shreyasminocha.me/chapters/character-classes an example is given which uses: o ^ character outside brackets o $ end of line o + But the explanation above does not introduce these yet, so a real beginner user (like me) is lost. The ambigious characters example is fine, since it uses all the concepts already explained.

Thanks. Yeah, others pointed this out too. I'll get to it soon!

Just wanted to chime in and also say that this is extremely confusing for a RegEx beginner, but thanks for your work, it looks really nice.

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#103
post #78

I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a…

The biggest problem I've noticed for regex is we use it every once in a while and once it works we move onto other things. And a few weeks/months later, we have forgotten much of it and have to relearn it all over again. Whereas, you generally use your programming language ( C++, C#, Java, etc ) everyday to keep your skills sharp, regex is generally "set it and forget it" situation for most people. And as you noted,…

Please do not forget the fact that after a couple of months, you want to make a small change, but you forgot the edge cases when you first created the regex :D

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#104

Earlier quoted context omitted.

The biggest problem I've noticed for regex is we use it every once in a while and once it works we move onto other things. And a few weeks/months later, we have forgotten much of it and have to relearn it all over again. Whereas, you generally use your programming language ( C++, C#, Java, etc ) everyday to keep your skills sharp, regex is generally "set it and forget it" situation for most people. And as you noted,…

Please do not forget the fact that after a couple of months, you want to make a small change, but you forgot the edge cases when you first created the regex :D

Unit tests will help with this.

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#105
post #78

I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a…

>what is a literal character and what is a control character?

I read a tip back in the Perl 5 book, that you can just escape any character if you don't remember if it has a special meaning. (You'll still get the literal character even if it didn't need escaping.)

So I basically do that a lot. Never had any issue with control characters.

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#106
post #85
post #78

I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a…

I don't see the problem here. The regex itself is exactly the same, it's just that different languages have different string literal syntaxes (and some have dedicated regex syntax, thus solving the problem of double-escaping). The only regex engine where this is a problem is Vim's, because there are characters that a special unless escaped, and characters that are normal but become special when escaped . And as if th…

> I don't see the problem here.

I think the problem is that it's like shooting off a boat in choppy waters. You not only have to decide what you're aiming at (problem #1), you have to anticipate how the motion of the boat will affect it (problem #2).

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#107
post #78

I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a…

Does this help? https://regex101.com

pretty good, for problem #1

actually, very good.

doesn't seem to address problem #2 unless I missed something

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#108
post #78

I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a…

The biggest problem I've noticed for regex is we use it every once in a while and once it works we move onto other things. And a few weeks/months later, we have forgotten much of it and have to relearn it all over again. Whereas, you generally use your programming language ( C++, C#, Java, etc ) everyday to keep your skills sharp, regex is generally "set it and forget it" situation for most people. And as you noted,…

I don't think regex is that specifically hard to learn, but you're fighting the escaping in your favorite language at the same time, so your learning is confounded.

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#109
post #78

I think what regex's need is a really powerful syntax and language aware regex editor. I've been using regexs for most of my career, and still struggle to get them right on first writing. The #1 problem I run into is: what is a literal character and what is a control character? for example, both these are very common: - match a parenthesis character or a period character - use a parenthesis to group a match or use a…

>what is a literal character and what is a control character? I read a tip back in the Perl 5 book, that you can just escape any character if you don't remember if it has a special meaning. (You'll still get the literal character even if it didn't need escaping.) So I basically do that a lot. Never had any issue with control characters.

In my example, if you over-escape the first period or under-escape the second period the regex will undermatch or overmatch.

for me it took a few tries to get filexc to not match and file.c to match in my example in the 3 languages.

Re: Show HN: RegEx for Regular Folk – A visual, example-based introduction

#110
post #101
post #59

Nice intro. Tangential question. Is there a regex tool that shows where the expression failed ? Not in syntax, but the logical failure point? Would be useful for when an expression gets a little long and nested and modifications need to be made. Edit: I mean like: Target text is abcde Regex is /abe/ Is there a tool that will tell me it matched a and b and then failed trying to match e ? Those sites are great resource…

You want a debugger. http://p3rl.org/rxrx rxrx -e'"abcde" =~ /abe/' Demo: https://blog-cloudflare-com-assets.storage.googleapis.com/20... http://p3rl.org/re#'debug'-mode perl -Mre=debug -e'"abcde" =~ /abe/' ---- https://stackoverflow.com/questions/2348694/how-do-you-debug...

Wow, where have I been. That’s awesome. Exactly what I was looking for . Thanks. My Google fu obviously is lacking.
Post reply on HN