Regex is great for very simple text processing, and I tend to do a lot of that.
The most important parts to get comfortable with are:
* Capture groups and alternation
* Character sets
* Anchors (start and end of line)
* Common escape sequences (digit, word, whitespace)
* Repeat (any, one or more, n-m)
* Common flags (global, multi-line, case-insensitive)
If you need more than that, it's time to start evaluating other tools IMO. A lookahead here and there is okay, but I'd avoid them if possible.
The best way I found to learn regex was to take a set of inputs that I wanted to match, (and a set that I didn't) and play around on https://regex101.com/ until I got a pattern that did what I wanted. You'll very quickly start to learn the above bulletpoints, and before long you'll be able to write patterns without any reference.
If you find that your regexes are getting too large or unwieldy or difficult to understand (despite knowing the above bulletpoints) then you probably need a parser or some other more suitable tool.
The most important parts to get comfortable with are:
* Capture groups and alternation
* Character sets
* Anchors (start and end of line)
* Common escape sequences (digit, word, whitespace)
* Repeat (any, one or more, n-m)
* Common flags (global, multi-line, case-insensitive)
If you need more than that, it's time to start evaluating other tools IMO. A lookahead here and there is okay, but I'd avoid them if possible.
The best way I found to learn regex was to take a set of inputs that I wanted to match, (and a set that I didn't) and play around on https://regex101.com/ until I got a pattern that did what I wanted. You'll very quickly start to learn the above bulletpoints, and before long you'll be able to write patterns without any reference.
If you find that your regexes are getting too large or unwieldy or difficult to understand (despite knowing the above bulletpoints) then you probably need a parser or some other more suitable tool.