▲ 246 ▼ rule (files.catbox.moe) submitted 1 month ago by spujb@lemmy.cafe to c/onehundredninetysix@lemmy.blahaj.zone 56 comments fedilink hide all child comments the original said reggae but i misread it as regex and got this idea lol original comic artist: thisstupidtwink@insta
[–] NOT_RICK@lemmy.world 16 points 1 month ago (1 child) Ugh I don’t miss having to parse someone else’s regex at my old job. permalink fedilink source hideshow 2 child comments replies: [–] jjj@lemmy.blahaj.zone 3 points 1 month ago (4 children) Is there a version of regex with comments? I mean one would typically insert it as a literal in another language but if there are flexible macros it could be done without any runtime cost/standard reinventing. permalink fedilink source parent hideshow 8 child comments replies: [–] blueduck@piefed.social 6 points 1 month ago PCRE supports inline comments: foo(?# match literal foo)\d+ Also verbose mode pattern = re.compile(r""" ^ # start of string [A-Z]{2} # two uppercase letters \d{4} # four digits $ # end of string """, re.VERBOSE) permalink fedilink source parent [–] trem@lemmy.blahaj.zone 2 points 1 month ago I've seen attempts of regex pre-processors, where you'd get some builder API like: pattern .digits(3) .literal(" - ") Can't use that in configurations, though, unless you template the configuration, I guess... permalink fedilink source parent [–] kartoffelsaft@programming.dev 2 points 1 month ago There is Backus-Naur form (and it's derivatives), which at least lets you name each section of text like you would a variable or function. Technically matches context-free expressions rather than regular ones but that's hardly different for most cases. permalink fedilink source parent [–] flamingos@feddit.uk 1 point 1 month ago Emacs has the rx macro: https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html permalink fedilink source parent
[–] jjj@lemmy.blahaj.zone 3 points 1 month ago (4 children) Is there a version of regex with comments? I mean one would typically insert it as a literal in another language but if there are flexible macros it could be done without any runtime cost/standard reinventing. permalink fedilink source parent hideshow 8 child comments replies: [–] blueduck@piefed.social 6 points 1 month ago PCRE supports inline comments: foo(?# match literal foo)\d+ Also verbose mode pattern = re.compile(r""" ^ # start of string [A-Z]{2} # two uppercase letters \d{4} # four digits $ # end of string """, re.VERBOSE) permalink fedilink source parent [–] trem@lemmy.blahaj.zone 2 points 1 month ago I've seen attempts of regex pre-processors, where you'd get some builder API like: pattern .digits(3) .literal(" - ") Can't use that in configurations, though, unless you template the configuration, I guess... permalink fedilink source parent [–] kartoffelsaft@programming.dev 2 points 1 month ago There is Backus-Naur form (and it's derivatives), which at least lets you name each section of text like you would a variable or function. Technically matches context-free expressions rather than regular ones but that's hardly different for most cases. permalink fedilink source parent [–] flamingos@feddit.uk 1 point 1 month ago Emacs has the rx macro: https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html permalink fedilink source parent
[–] blueduck@piefed.social 6 points 1 month ago PCRE supports inline comments: foo(?# match literal foo)\d+ Also verbose mode pattern = re.compile(r""" ^ # start of string [A-Z]{2} # two uppercase letters \d{4} # four digits $ # end of string """, re.VERBOSE) permalink fedilink source parent
[–] trem@lemmy.blahaj.zone 2 points 1 month ago I've seen attempts of regex pre-processors, where you'd get some builder API like: pattern .digits(3) .literal(" - ") Can't use that in configurations, though, unless you template the configuration, I guess... permalink fedilink source parent
[–] kartoffelsaft@programming.dev 2 points 1 month ago There is Backus-Naur form (and it's derivatives), which at least lets you name each section of text like you would a variable or function. Technically matches context-free expressions rather than regular ones but that's hardly different for most cases. permalink fedilink source parent
[–] flamingos@feddit.uk 1 point 1 month ago Emacs has the rx macro: https://www.gnu.org/software/emacs/manual/html_node/elisp/Rx-Notation.html permalink fedilink source parent