Comment

Comment by miki123211

TBH, I feel like regexes would be much easier to understand in a more literate form with standard syntax. Something like:

  user_part = re.repeat(re.alnum | re.chars(".-_+"))
  domain_segment = re.repeat(re.alnum)
  domain = re.list(domain_segment,separator=".",minimum=2)
  email_address = user_part + "@" + domain
Where, in a real program, `domain` would be defined in a "standard library of constructions" that you can just import and re-use in more complicated regexes.

Something like this can be implemented in any language with operator overloading, no DSL required. Without operator overloading, the syntax would be a bit more awkward, but still nicer than the current regexp madness.

parent miki123211 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton