3 ms·
Yes, you are (of course) able to replace all occurrences today. However, you either need to call replace multiple times or pollute your code with a regex. This
by sveingjoby 7y ago
Yes, you are (of course) able to replace all occurrences today. However, you either need to call replace multiple times or pollute your code with a regex. This would certainly improve the readability.
- pier25 7y agoWhy would using regex pollute your code?
- Normal_gaussian 7y agoIt depends on who you ask; however the thinking is often: * They can indicate poor parsing (ie can't read xml with regex) and failure to use programmatic methods (e.g parsing command output rather than making syscalls) * regexes are very easy to write incorrectly without being obviously wrong * regexes are often overkill for a direct match * regexes invite people to make it more complex rather than restructure surrounding code * regexs are comparatively more expensive than alternative code * to work on the codebase you are now required to understand regex in general and this particular implementations quirks as well I often use regexes, and I often choose not to use regexes.