this post was submitted on 01 Dec 2024
86 points (100.0% liked)
askchapo
22836 readers
200 users here now
Ask Hexbear is the place to ask and answer ~~thought-provoking~~ questions.
Rules:
-
Posts must ask a question.
-
If the question asked is serious, answer seriously.
-
Questions where you want to learn more about socialism are allowed, but questions in bad faith are not.
-
Try !feedback@hexbear.net if you're having questions about regarding moderation, site policy, the site itself, development, volunteering or the mod team.
founded 4 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Imagine still using regexes in current year. Every language has a parser combinator library, now, just write a damn parser and stop pretending you remember what a regular language is or that the garbage text you're processing is a sentence in one.
I'm the sicko doing regex find and replace in notepad++
Looking forward to being able to start a consulting firm when my arcane knowledge is worth a premium
Should add treesitter to your toolbox. Never mind regex-replace when you can exploit the syntax of the actual programming language to do rich query-replace actions. 🌞
That's neat! I mostly use regex for like columns of text data. I think most people use excel but I hates it. Nasty little microsofts
This sounds useful
How do I learn to do it
Read this for a very light introduction to the concept, then type "parser combinator library " into a search engine and never maintain a regular expression again!
How does this method handle backtracking? It seems like, as written, those functions wouldn’t handle it
Some implementations don't support backtracking at all, but ones that do will have combinators like
where
atomic
andchoice
are parsers that take other parsers as arguments likeand
andor
in the article, though the advice is to avoid backtracking whenever possible since it's quite expensive. The little examples in the post are just a taste to make the idea legible, but not really suited for especially interesting parsers.I've learned something new today
I use regex because I don't know what is a parser combinator library or how to acesss one. Why would i learn how to write a parser when I have a perfectly adequate, portable, thoroughly documented tool available?