Live data from Hacker News

Show HN: Luna is a Clojure domain specific language that translates to regex

github.com

1–10 of 22 posts

Re: Show HN: Luna is a Clojure domain specific language that translates to regex

#2
I'm not totally convinced by these English-like regex languages. Regex itself seems like a reasonable language:

[a-z] means a to z

x* means 0 or more xs

...

The problem is that

a) whitespace is significant, so long regexes start to become unreadable

b) no easy way to nest regexes

Perl 6/Raku seemed to solve this by making whitespace meaningless by default and allowing regexes to be nested into other regexes or entire "grammars".

Re: Show HN: Luna is a Clojure domain specific language that translates to regex

#6

EDIT: This comment is wrong, I've mistakenly read `(?<=y)x` as `(?=y)x` and wrongly determined the key ":after" is incorrect when writing this comment.

I’m confused. Given a string “foobar”, `(?<=foo)bar` should match “bar”. Or is this implicitly `^(?<=foo)bar$` in Clojure? I used to know the answer but it’s been several years since I’ve used Clojure.

Re: Show HN: Luna is a Clojure domain specific language that translates to regex

#7
post #2

I'm not totally convinced by these English-like regex languages. Regex itself seems like a reasonable language: [a-z] means a to z x* means 0 or more xs ... The problem is that a) whitespace is significant, so long regexes start to become unreadable b) no easy way to nest regexes Perl 6/Raku seemed to solve this by making whitespace meaningless by default and allowing regexes to be nested into other regexes or entire…

Completely agree. For js, xregexp [1] is a really nice long standing library that brings in these kind of enhancements and makes regular expressions a lot more readable.

[1] https://xregexp.com

Re: Show HN: Luna is a Clojure domain specific language that translates to regex

#8

EDIT: This comment is wrong, I've mistakenly read `(?<=y)x` as `(?=y)x` and wrongly determined the key ":after" is incorrect when writing this comment.

I’m confused. Given a string “foobar”, `(?<=foo)bar` should match “bar”. Or is this implicitly `^(?<=foo)bar$` in Clojure? I used to know the answer but it’s been several years since I’ve used Clojure.

Oops, I've mistakenly thought `(?=foo)bar` when writing that comment. Please disregard the parent comment.

Re: Show HN: Luna is a Clojure domain specific language that translates to regex

#9
I like to think of DSL's for regex as a good way for people who don't have time to master regex itself, or are beginners, to actually use regex. Been doing programming for about 10 years and only fairly recently took the time to properly learn regex, but could've definitely benefitted from a DSL way before that. Good job Abhinav!
Post reply on HN