I sometimes wonder what a syntactically clarified regex could look like. There are two things that often confuse newcomers:
- What are escapes are and what needs to be escaped? - The structure of a regex. - Syntax around things like capture (is the parens part of some matcher? what to escape?) We should have a version of regex that separates characters, character classes and operators, or whatever the regex jargon for those things are. Half the things I usually want to regex for, like parens on a function or dot accessors need to be escaped! A quick example for illustration purposes (please don't point out why this grammar wont map to regex):
(['a' or 'b']<2,4,greedy>, captureAs="prefix")[number or '.']<2>
is definitely more approachable and easier to explain than the regex equivalent (which I'm avoiding to write because I don't have time to test if I got capture syntax right).
Maybe someone makes a wasm regex-simple transformer we can use in multiple languages. Regex is too useful to have such a scary syntax for newcomers!
I think most people just like to hate on regex syntax because when just glanced over it looks like spilled tea leaves.
However I'd argue that it's not actually very hard to learn and its brevity makes it easier to retain. (personally I did so using https://www.regular-expressions.info/tutorial.html) I agree that escaping is a problem, mainly because languages have often different rules for this.
I started teaching Python to my GF(she is working from home and now has plenty of time to do some extra learning). She is not a programmer and I have been giving her small functions to write. Recently, we started with RegEx and she finds it really hard to get into. She wants to see examples and follow along. I think this will be perfect for her and anyone starting out to learn regex.
I noticed that in the "Escapes" chapter, the "Next" link at the bottom of the page goes back to the introduction when it should go to "Groups". I poked around in your repo to try and submit a pull request, but I can't tell where the edit needs to go; the meta.json file seems to have an array with the right chapter headings which was my guess about the problem. Anyway, there is a typo. Sorry I can't be more helpful when you've put together such a great resource. https://github.com/shreyasminocha/regex-for-regular-folk/blo...
Comments (108) 46 threads
Earlier comments- What are escapes are and what needs to be escaped?
is definitely more approachable and easier to explain than the regex equivalent (which I'm avoiding to write because I don't have time to test if I got capture syntax right).- The structure of a regex.
- Syntax around things like capture (is the parens part of some matcher? what to escape?)
We should have a version of regex that separates characters, character classes and operators, or whatever the regex jargon for those things are. Half the things I usually want to regex for, like parens on a function or dot accessors need to be escaped!
A quick example for illustration purposes (please don't point out why this grammar wont map to regex):
Maybe someone makes a wasm regex-simple transformer we can use in multiple languages. Regex is too useful to have such a scary syntax for newcomers!
However I'd argue that it's not actually very hard to learn and its brevity makes it easier to retain. (personally I did so using https://www.regular-expressions.info/tutorial.html)
I agree that escaping is a problem, mainly because languages have often different rules for this.
I noticed that in the "Escapes" chapter, the "Next" link at the bottom of the page goes back to the introduction when it should go to "Groups".
I poked around in your repo to try and submit a pull request, but I can't tell where the edit needs to go; the meta.json file seems to have an array with the right chapter headings which was my guess about the problem.
Anyway, there is a typo. Sorry I can't be more helpful when you've put together such a great resource.
https://github.com/shreyasminocha/regex-for-regular-folk/blo...
It was fairly unintuitive for someone unfamiliar with the source, so no worries :D
All comments shown.
Couldn't load more comments. Check your connection and try again.