Python re(gex)?

Learning and science

programming book

SHOW HN2019

193points
50comments
#197of 2,195 in 2019
Top 9%of 2019 by points

How HN took it

MixedNo clear lean

5 positive, 2 neutral or asking, 0 mixed, 2 critical, out of 9 comments about the project. Thread score +0.32.

Docs: 3 for, 0 againstIdea: 0 for, 2 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Helpful resource and well done on the book

    From 3 comments
    • Congrats on writing and publishing this book!
      nathanbarry on HN
    • This is a great resource. Thank you for taking the time to write this and making it available to us!
      dhairya on HN
    • This is super helpful! I've always felt Python regex was one of the more complicated parts of the language.
      spazzy81 on HN
  • Interesting alternative regex syntax via rxe library

    From 2 comments
    • This is excellent, I prefer this.
      PieUser on HN
    • You might like: https://github.com/mtrencseni/rxe So you can write: ``` username = rxe.one_or_more(rxe.set([rxe.alphanumeric(), '.', '%', '+', '-'])) domain =…
      Maro on HN

Objections

  • Regex is hard to read and often overused; parsers are better

    From 2 comments
    • There two kinds of text search/parse problems: - The really easy ones. A simple string search/split will do and a regex would be overkill. - The really hard ones. You'll need to…
      AlexanderDhoore on HN
    • I couldn't agree more. I honestly find it rather baffling that someone would write a book on not just regular expressions in general, but one particular variant in one particular…
      IceDane on HN
  • Dedicated Python regex book seems unnecessary since regex is language agnostic

    From 2 comments
    • I couldn't agree more. I honestly find it rather baffling that someone would write a book on not just regular expressions in general, but one particular variant in one particular…
      IceDane on HN
    • None that I know of. My thought process has always been that regex was language agnostic. I think Perl has its own version that is widely used. But other than that, I do not know.
      just_myles on HN
  • Rxe style is too verbose

    From 2 comments
    • Too verbose, I prefer good old regular expression.
      gnulinux on HN
    • 10 lines to replace maybe 20 characters. How horribly verbose.
      qwsxyh on HN

Questions

  • Why Python regex differs from other languages

    From 1 comment
    • > My thought process has always been that regex was language agnostic. +1 I was surprised to find that regex in python was not much different from the language I use ruby. Would…
      Lordarminius on HN
  • Whether Python's re supports variable-length lookbehind

    From 2 comments
    • Thanks for sharing! I only skimmed it but I liked how you include usage of the external regex module, which I hadn't realized allowed for the use of variable-length look-behinds.
      danso on HN
    • The engine has support but the language doesn't expose it?
      ErikCorry on HN

Alternatives named

  • rxe library

    From 1 comment
    • You might like: https://github.com/mtrencseni/rxe So you can write: ``` username = rxe.one_or_more(rxe.set([rxe.alphanumeric(), '.', '%', '+', '-'])) domain =…
      Maro on HN
  • CommonRegex module

    From 1 comment
    • I actually find these too verbose. May be because I didn't know about them when I started out, was using regex in cli tools and Perl scripts. There's also a module [1] which…
      asicsp on HN
  • Parser combinators and PEG grammars

    From 2 comments
    • Parser combinators are the way to go. I don't use python often enough to know if such a library exists for python, but I would assume so.
      IceDane on HN
    • No experience with them in python, but look also for PEG grammars. They are significantly simpler than the traditional tower of lexer + ambiguous limited lookahead grammar. Plus…
      cben on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/20645319)