Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Regular Expressions

Hopefully there is a solution to that! Instead of trying to validate strings in different combinations and character by characters we can achieve everything in one line! How?

Regular Expressions come to the rescue! 

Regular expressions are a compact way to define in one line an abstract layout of how an accepted string (or value that comes from data) should look like.

Be careful! Regular expressions (or RegEx as they are called for economy), are no subject to JavaScript as language. They are only a way to define patterns and they work well with many other languages as well (python, ruby etc).

Let's leave aside the 'how' and focus a bit on 'why'. Especially what is the problem they solve?