Regex is harder to understand because one should be aware of the peculiarities of each language. Besides, it uses abbreviations such as "i", "u", "g" and the one reading it might need to look at the docs to know what that means.
str-replace uses regex internally but abstracts it in a fluent interface for legibility purposes at the cost of not optimizing prematurely. Regex is definitely the solution if one want to make more complex replaces or need to care about micro-optimizations like the use of regex without an additional function call (which imho in 90% of the cases is irrelevant).
str-replace uses regex internally but abstracts it in a fluent interface for legibility purposes at the cost of not optimizing prematurely. Regex is definitely the solution if one want to make more complex replaces or need to care about micro-optimizations like the use of regex without an additional function call (which imho in 90% of the cases is irrelevant).