Live data from Hacker News

RegExpBuilder – Create regular expressions using chained methods

github.com

1–10 of 56 posts

Re: RegExpBuilder – Create regular expressions using chained methods

#2
Thanks, this is a lot better than writing this (even if the formatting worked here):

``` (?xi) \b ( # Capture 1: entire matched URL (?: [a-z][\w-]+: # URL protocol and colon (?: /{1,3} # 1-3 slashes | # or [a-z0-9%] # Single letter or digit or '%' # (Trying not to match e.g. "URI::Escape") ) | # or www\d{0,3}[.] # "www.", "www1.", "www2." … "www999." | # or [a-z0-9.\-]+[.][a-z]{2,4}/ # looks like domain name followed by a slash ) (?: # One or more: [^\s()]+ # Run of non-space, non-() | # or \(([^\s()]+|(\([^\s()]+\)))\) # balanced parens, up to 2 levels )+ (?: # End with: \(([^\s()]+|(\([^\s()]+\)))\) # balanced parens, up to 2 levels | # or [^\s`!()\[\]{};:'".,?«»“”‘’] # not a space or one of these punct chars ) ) ```

Re: RegExpBuilder – Create regular expressions using chained methods

#3
post #2

Thanks, this is a lot better than writing this (even if the formatting worked here): ``` (?xi) \b ( # Capture 1: entire matched URL (?: [a-z][\w-]+: # URL protocol and colon (?: /{1,3} # 1-3 slashes | # or [a-z0-9%] # Single letter or digit or '%' # (Trying not to match e.g. "URI::Escape") ) | # or www\d{0,3}[.] # "www.", "www1.", "www2." … "www999." | # or [a-z0-9.\-]+[.][a-z]{2,4}/ # looks like domain name followed…

HN doesn't support Markdown. You'll need to prefix each line with >= 2 spaces for it to be treated as code.

https://news.ycombinator.com/formatdoc

Re: RegExpBuilder – Create regular expressions using chained methods

#6
Generally, I find that if one's regexes are so complex that one needs visualizers or other aids in writing them, one doesn't have a regex problem, but a parsing problem. The method of parsing by recursive descent can often lead to much more understandable (if more verbose) "pattern matching".

Re: RegExpBuilder – Create regular expressions using chained methods

#8
Looks like Linq (from .Net/C#). Pretty sexy way to write Regular Expressions if you ask me.

I've "learned" regular expressions multiple times but it just never sticks, I have no idea why. It certainly doesn't help that there are several different incompatible syntaxes (so what I remember and think "should" work doesn't).

I'd prefer to write RegX's in this style, however I would pay attention to performance (not that Regular Expressions are high performance, however I wouldn't want to see a large performance loss either).

Re: RegExpBuilder – Create regular expressions using chained methods

#9
post #3
post #2

Thanks, this is a lot better than writing this (even if the formatting worked here): ``` (?xi) \b ( # Capture 1: entire matched URL (?: [a-z][\w-]+: # URL protocol and colon (?: /{1,3} # 1-3 slashes | # or [a-z0-9%] # Single letter or digit or '%' # (Trying not to match e.g. "URI::Escape") ) | # or www\d{0,3}[.] # "www.", "www1.", "www2." … "www999." | # or [a-z0-9.\-]+[.][a-z]{2,4}/ # looks like domain name followed…

HN doesn't support Markdown. You'll need to prefix each line with >= 2 spaces for it to be treated as code. https://news.ycombinator.com/formatdoc

That really is Hacker News' worst limitation. I understand if they want to limit what formatting is available, but the fact that basic listing is so clunky is annoying.
Post reply on HN