Live data from Hacker News

Common Regular Expressions Made Simple

github.com

21–25 of 25 posts

Re: Common Regular Expressions Made Simple

#21

I am reminded of VerbalExpressions https://github.com/VerbalExpressions which hit HN in early August. Interested in learning more about regex's I did some work on a Racket port. That project shows there are two tracks by which to tackle the problem that regex syntax is incoherent gobbledygook. The first is creating a regex version of pho with 5000 functions and mix and match names piece by piece. The second is to ren…

Very good point! It's not the reasoning and logic behind regex that would turn a beginner away from it, its the syntax that is being used that often results into expressions turning into impenetrable goo!

(thanks for the verbal expressions link btw, seems really promising)

Re: Common Regular Expressions Made Simple

#22
post #5

Earlier quoted context omitted.

The time regex is, too. In German you can expect to encounter the text fragment > um 6:00 am 05.12. (at 6:00 on 12/05/..) If i read it correctly, the time regex would extract "6:00 am" as time, but the "am" is wrong (German uses 24h format).

When dealing with this general problem, the proper tool would more likely be language/culture detection + Named-Entity Recognition. Simple regular expressions can be good enough if you're aware of the domain restriction though.

Yeah, I threw together this module intending to supplement NER on a text classification project I'm currently working on, not as a replacement for NER.

Re: Common Regular Expressions Made Simple

#23
post #4

Earlier quoted context omitted.

I'm gonna be That Other Other Guy and say....stuff like this is the reason why most programmers I meet take ages to do anything custom. Evey body uses this framework and that library and make bulky code that could actually be implemented with 2 far more efficient lines and will struggle when the need to customize presents itself. Learn Regex...you will have a crazy powerful weapon in your arsenal.

Why is this being downvoted? This is an excellent point. Petty substitutions like verbal expressions might be useful if you're just getting started, but ultimately it's a crutch and it's best just to learn pure regular expressions. They're not that difficult. Same with bundling a ton of dependencies. Lots of people (especially contemporary programmers, primarily web developers) seem to be deathly afraid of writing cu…

It really shouldn't have been downvoted.

Re: Common Regular Expressions Made Simple

#25
post #2

I'm gonna be That Guy and say that the e-mail regex isn't upto scratch and probably should not be included. generally, very good.

I'm gonna be That Other Guy and say that the date and phone regex are respectively english-language and US specific. So it's common for a narrow definition of common.

The author does explicitly note that in the readme:

> Please note that this module is currently English/US specific.

Post reply on HN