the original said reggae but i misread it as regex and got this idea lol

original comic artist: thisstupidtwink@insta

  • a_jeering_serpent@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 days ago

    Thank you friend! I honestly had almost forgotten that you could + on a group (in extended syntax i think?) like you can with *. In my experience I find lots of * groups and I do my best to convert those to a range eg {3,5}. When you can’t typically you can set least still use an open range floor {3,} or ceiling {,5}. I’m a big fan of explicit constraints when you have enough information to set them. It’s another good maintainability practice in my experience. The more clear the regex the less example data you need to understand the intention. I especially like eg ruby’s regexp.x flag that let’s you ignore literal newlines and whitespace in the pattern (not to be confused with regexp.X which does the same but for the corpus), so you can split your pattern over multiple lines. I like to use indentations when it helps readability and that also allows a multi line comment header indented the same way. Sometimes you can even set inline comments depending on language/engine/syntax. For significant whitespace in the pattern wrap each whitespace character in a character class containing only itself: eg [ ][ ] for two literal spaces to match. This is also how I handle patterns for eg sed or grep in bash/zsh which have their own whitespace semantics, to get whitespace literals in your patterns without the need to escape anything. The non-literal part of the pattern doesnt change, and the literal part gets substituted in piped through something like sed -E ‘/./[\1]/g’