cm0002@lemmy.world to Programmer Humor@programming.dev · 9 days agowhat debugging regex feels likelemmy.mlimagemessage-square73fedilinkarrow-up1905arrow-down114cross-posted to: programmerhumor@lemmy.ml
arrow-up1891arrow-down1imagewhat debugging regex feels likelemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 9 days agomessage-square73fedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squarelmmarsano@lemmynsfw.comlinkfedilinkEnglisharrow-up2·edit-28 days agoElisp has a nice notation for maintainably composing regexes like any other programming expression. Only language I’ve seen offer that. So instead of "/\\*\\(?:[^*]\\|\\*[^/]\\)*\\*+/", the regular expression to match C block comments could be expressed (with inline comments) (rx "/*" ; Initial /* (zero-or-more (or (not (any "*")) ; Either non-*, (seq "*" ; or * followed by (not (any "/"))))) ; non-/ (one-or-more "*") ; At least one star, "/") ; and the final /
Elisp has a nice notation for maintainably composing regexes like any other programming expression. Only language I’ve seen offer that. So instead of
"/\\*\\(?:[^*]\\|\\*[^/]\\)*\\*+/"
, the regular expression to match C block comments could be expressed (with inline comments)