One common use of regular expressions is for form validation. Using regular expressions, we can check to ensure that password use the correct characters, that email addresses contain domain information, and more. In this learning activity, we’ll create various regular expressions to validate a number of fields in a registration form, making sure our front-end users can create accounts.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Set the regex expression for the name value.
Define a regular expression for the
name_val
.- Set the regex expression for the email value.
Define an
email_var
regular expression.- Set the regex expression for the username value
Define the regular expression for the
username_val
variable.- Set the regex for the password value.
Set
password_val
to an appropriate regular expression.- Set the regex for the credit card value.
Set
credit_val
to a regular expression to match a credit card.