Are regular expressions worth the hassle?

后端 未结 24 1414
说谎
说谎 2020-12-03 13:58

It strikes me that regular expressions are not understood well by the majority of developers. It also strikes me that for a lot of problems where regular expressions are use

24条回答
  •  伪装坚强ぢ
    2020-12-03 14:17

    I'm thinking in terms of maintenance of the code rather that straight line execution time.

    Code size is the single most important factor in reducing maintainability.

    And while Regexps can be very hard to decipher, so are 50 line string processing methods - and the latter are more likely to contain bugs in rare corner cases.

    The thing is: any non-trivial regexp must be commented just as thoroughly as you'd comment a 50 line method.

提交回复
热议问题