When not to use Regex in C# (or Java, C++, etc.)

后端 未结 7 1238
囚心锁ツ
囚心锁ツ 2020-11-28 13:12

It is clear that there are lots of problems that look like a simple regex expression will solve, but which prove to be very hard to solve with regex.

<
7条回答
  •  孤独总比滥情好
    2020-11-28 13:53

    You should always learn regular expressions - only this way you can judge when to use them. Normally they get problematic, when you need very good performance. But often it is a lot easier to use a regex than to write a big switch statement.

    Have a look at this question - which shows you the elegance of a regex in contrast to the similar if() construct ...

提交回复
热议问题