in reply to Style question: regex versus string builtin function
What if the intention is that metacharacters in the variable should be used as such? What to use depends on what the intention is.
For cases where "TMTOWTDI" really applies, the choice of approach is not likely to matter all that much (except to those who are compelled to optimize). For cases where literal-vs.-metachar handling means a difference between success vs. error (or ability vs. inability to do a task), one tool will be better than the other, and whichever one is right, you still have to provide some safeguards and checks to try to handle all contingencies as best you can.
|
|---|