Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Well no that isn't how it works

$
0
0
Rant about regex taken from the Code Project newsletter links. Figured I might as well put a response here.

Regular Expressions make me feel like a powerful wizard – and that’s not a good thing – Terence Eden’s Blog[^]

"The other day I had to fix a multi-line Regular Expression (RegEx). After a few hours of peering at it with a variety of tools,"


But the author doesn't suggest that there was in fact a different way to approach the problem.

"There's no space for comments"


Well no that isn't true.

For starters Perl language actually allows embedded comments although I would not use them.
However I can certainly explain the regex, and often do, outside of the regex itself.
Of course some few complain that code, all code, should not have comments at all but that is a personal problem.

"Here are some positive use-cases for RegEx":


Obviously just sarcasm but missing the point that there is a range of problems where regexes should be used. The solution to not using them would be to write the code that the regex represents in the first place. Which would be much more verbose and more likely the source of errors.

There are actually however cases of misuse that are not named where someone thinks they can avoid other types of solutions by incorrectly applying regexes. That is often the case for XML/HTML parsing.

"We should be writing intelligible code for each other"


Agreed. But there are always trade offs. I can't write code that a junior developer is going to easily understand and still produce code at the rate at which I do. Doesn't mean that I should write code that a mid level or even senior level developer is going to have to spend days figuring out. And I do try to make it easier for them to understand (often by adding comments to explain odd constraints and/or external factors.)

Viewing all articles
Browse latest Browse all 224

Trending Articles