2 ms·
Word of caution: Regex is hard to maintain. They are harder to (re)read than C-Style languages.
by senthil_rajasek 7y ago
Word of caution: Regex is hard to maintain. They are harder to (re)read than C-Style languages.
- ridiculous_fish 7y agoRegex can be as easy to maintain as code, if you treat them like code: 1. Don't put it all on one line 2. Indent nested constructs 3. Write comments See for example Python's verbose regex syntax: https://docs.python.org/3/library/re.html#re.VERBOSE https://docs.python.org/3/library/re.html#re.VERBOSE
- senthil_rajasek 7y agoThe verbose mode helps a bit. I did a quick check and C# seems to have tricks to accomplish "verbose" RE. But still, if you have to comment RE to improve readability is that really an improvement or one more thing to maintain? My preference is to avoid RE in larger code bases.