3 ms·
Do you remember at least: . * | + ? ( ) This is 95% of it. After that, it's character classes and lazy matching. Character classes can often be given as ra
by ogogmad 4y ago
Do you remember at least:
. * | + ? ( )
This is 95% of it. After that, it's character classes and lazy matching.
Character classes can often be given as ranges:
[a-z] [A-Z] [0-9] ^ $
You can use the pipe | to combine then.
Lazy matching finds the shortest matching string instead of the longest one. This is given by the symbols:
*? +?
Instead of + and * respectively.
> I only use it once per year
If you use a text editor, any kind of repetitive find+replace activity can be sped up using regexes. Seems strange you only use it once per year.
Some people tell you that you can't parse XML using regexes. THEY'RE WR- right, but you can often do decent one-off jobs on an XML document using regular expressions, as long as you're aware that it's a one-off job that won't work on any other document.
- throwaway9870 4y agoIt is not that it is hard to understand the syntax or even write them, it is hard to read and change them. Here is an example I just grabbed off a random webpage: ^(?=.\d)(?=.[a-z])(?=.[A-Z])(?=.[!@#$^&()_-]).{8,18}$ That is hard to quickly* read and understand what it is. Sure a comment would help, but if someone said it isn't working, I have to work all that out and then fix it. There is a reason Perl lost to Python. It just seems like we can do better.
- Garlef 4y agoAnd that's an expression without any escaped parens, braces, etc.