When is a issue too complex for a regular expression?

后端 未结 13 1281
执念已碎
执念已碎 2021-02-01 19:42

Please don\'t answer the obvious, but what are the limit signs that tell us a problem should not be solved using regular expressions?

For example: Why is a complete emai

13条回答
  •  没有蜡笔的小新
    2021-02-01 20:20

    A few things to look out for:

    1. beginning and ending tag detection -- matched pairing
    2. recursion
    3. needing to go backwards (though you can reverse the string, but that's a hack)

    regexes, as much as I love them, aren't good at those three things. And remember, keep it simple! If you're trying to build a regex that does "everything", then you're probably doing it wrong.

提交回复
热议问题