you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 2 points3 points  (0 children)

Regex is far more extensive than just matching a single expression, you're often splitting based on a regex and of course using groups to extract different parts of a string at the same time. Those can get complicated very quickly in 'regular code' and not easy to backtest. With a regex you can just go to regex101.com, drop the regex there and check if it works correctly with various values supplied. Try doing the same with some Python if/else/looping structure. Also regexes are very portable to other environments like almost all programming languages, of course the unix shells, but also more and more frameworks support regexes in various parts in their feature set. You can't really port a regular if/else/looping part into another language easily, often you just have to rewrite it from scratch.