If you focus on the exceptions, you'll never program

Published:

by

You can't use regex to parse HTML. If you want to match all valid emails with regex, this is the most valid pattern:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

If you use the latest JavaScript features, chances are it will fail many devices.

If you want to properly display people's name, you'll have to support Unicode. If you plan to use toUppowerCase() or toLowerCase() to capitalize a name, you have to think about the names that are not written in ASCII.

If you want to support emojis, you have to update all the functions that check the length of a text. Does it support counting multi-byte characters?

If you write in Object Oriented Programming, will you switch to functional to save memory?

If your website runs slow with five thousand database records, how would you deal with 5 million records?

If your users turn off JavaScript, can they still use your website?

If you focus on all these exceptions and the many more I haven't included, chances are you will never start programming. The key is to build stuff anyway and face each problem as they come to life.