Live data from Hacker News

Common Regular Expressions Made Simple

github.com

1–10 of 25 posts

Re: Common Regular Expressions Made Simple

#3
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.

Re: Common Regular Expressions Made Simple

#4
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.

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.

Re: Common Regular Expressions Made Simple

#5
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 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).

Re: Common Regular Expressions Made Simple

#6
post #5

Earlier quoted context omitted.

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 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.

Re: Common Regular Expressions Made Simple

#7
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.

Previous discussion & article about why you just shouldn't bother with email regexes at https://news.ycombinator.com/item?id=5763327

Re: Common Regular Expressions Made Simple

#8
post #5

Earlier quoted context omitted.

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 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).

Haha that's excellent. Reminds me of a normalisation rule I wrote as part of a larger system to convert "Joe Bloggs Md." into "Dr. Joe Blogs MD" (where MD is Medical Doctor). TIL that "Md." is a common abbreviation for "Mohammed" in large parts of the world...

Re: Common Regular Expressions Made Simple

#9
post #5

Earlier quoted context omitted.

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 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).

"Um 12:30 am..." seems like a better example, since 6:00 is still 0600, but one parsing would make 12:30 am into 0030 rather than the intended 1230.
Post reply on HN