Once you learn the art of using regular expressions you can use it with many computer languages.
The following is how regular expressions can be used [abc] – find any character in the brackets a, b or c [a-z] – find the range of characters within brackets i.e. Can also be used with numbers [0-9] [^xyz] – find any character other than the ones specified in the brackets i.e.
We want to allow only letters, numbers and underscopes.
validate Password ( ) The function below checks the password field for blankness and allow only letters and numbers - no underscopes this time.
Using regular expressions the entered content can be validated with advanced conditions like the string entered shouldn’t contain spaces, special characters, numbers, uppercase or lowercase etc.
This wont be perfect validation it is possible to slip not compliant addresses by it but it's normally good enough.
validate Phone ( ) The function below checks if the phone number is valid.
Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign.
At first we check if the user entered anything at all in the email field.