DEV Community

Discussion on: Regex Bootcamp (or Nobody Seems to be Using HTML5 Validation)

Collapse
 
dexygen profile image
George Jempty

You realize regex's ARE declarative? "Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions": en.wikipedia.org/wiki/Declarative_...

Collapse
 
qm3ster profile image
Mihail Malo • Edited

Sure, and you could even reverse-engineer some messages, but you'd get something like

Phone must begin with "00" or "+" or nothing, followed by "1" or "7" or "20" or "27" or "3...

Whereas with a proper syntax description you could automatically insert a "+", delete a leading "00", and if the following two digits aren't a real country code have an informative error like

Please include the country code in the phone number