Why are people using regexp for email and other complex validation?

后端 未结 12 1351
感情败类
感情败类 2020-12-16 16:01

There are a number of email regexp questions popping up here, and I\'m honestly baffled why people are using these insanely obtuse matching expressions rather than a very si

12条回答
  •  清酒与你
    2020-12-16 17:02

    People write regular expressions because most developers like so solve a simple problem in the most "cool" en "efficient" way (which means that it should be as unreadable as possible).

    In Java, there are libraries to check if a String represents an email address without you having to know anything about regular expressions. These libraries should be available for other languages aswel.

    Like Jamie Zawinski said in 1997: "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."

提交回复
热议问题