VegOwOtenks@lemmy.world to Programmer Humor@lemmy.mlEnglish · 4 months agoRegex flavorslemmy.worldimagemessage-square20fedilinkarrow-up1105arrow-down15
arrow-up1100arrow-down1imageRegex flavorslemmy.worldVegOwOtenks@lemmy.world to Programmer Humor@lemmy.mlEnglish · 4 months agomessage-square20fedilink
minus-square☆ Yσɠƚԋσʂ ☆@lemmy.mllinkfedilinkarrow-up2·4 months agoI really like this approach for doing non trivial regex https://github.com/VerbalExpressions const tester = VerEx() .startOfLine() .then('http') .maybe('s') .then('://') .maybe('www.') .anythingBut(' ') .endOfLine();
minus-squarefrezik@midwest.sociallinkfedilinkarrow-up1·edit-24 months agoI don’t. It may look less like line noise, but it doesn’t unravel the underlying complexity of what it does. It’s just wordier without being helpful. https://www.wumpus-cave.net/post/2022/06/2022-06-06-how-to-write-regexes-that-are-almost-readable/index.html Edit: also, these alternative syntaxes tend to make some easy cases easy, but they have no idea what to do with more complicated cases. Try making nested capture groups with these, for instance. It gets messy fast.
I really like this approach for doing non trivial regex https://github.com/VerbalExpressions
const tester = VerEx() .startOfLine() .then('http') .maybe('s') .then('://') .maybe('www.') .anythingBut(' ') .endOfLine();
I don’t. It may look less like line noise, but it doesn’t unravel the underlying complexity of what it does. It’s just wordier without being helpful.
https://www.wumpus-cave.net/post/2022/06/2022-06-06-how-to-write-regexes-that-are-almost-readable/index.html
Edit: also, these alternative syntaxes tend to make some easy cases easy, but they have no idea what to do with more complicated cases. Try making nested capture groups with these, for instance. It gets messy fast.