3 ms·
In addition to the 'practice' stated elsewhere, the other thing someone needs to really get to grips with something like regex is a 'reason'. I never really go
by Zhyl 7y ago
In addition to the 'practice' stated elsewhere, the other thing someone needs to really get to grips with something like regex is a 'reason'.
I never really got the point of regexes until I discovered capture groups. Pretty much everything I use them for is based on some problem like:
"Change date format from 'DD-MM-YY' to 'YYYY-MM-DD'"
"Keep only lines in the log file with a date in them"
"Swap the first name and last name of every contact in this list which has a comma in it"
"Rename all the files in this folder to strip out all the gubbins and put the useful stuff in a standard format"
And so on. You need a problem where doing it any other way than regex would be lengthy and painful and the regex itself is light and breezy. You build up little snippets or "phrases" that you can re-use easily to solve new problems.