When is a issue too complex for a regular expression?

后端 未结 13 978
执念已碎
执念已碎 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:24

    Whenever you can't be sure it really solves the problem, for example:

    • HTML parsing
    • Email validation
    • Language parsers

    Especially so when there already exist tools that solve the problem in a totally understandable way.

    Regex can be used in the domains I mentioned, but only as a subset of the whole problem and for specific, simple cases.

    This goes beyond the technical limitations of regexes (regular languages + extensions), the maintainability and readability limit is surpassed a lot earlier than the technical limit in most cases.

提交回复
热议问题