Some Regular Expression (RegEx) Syntax Worth To Used

Regular Expression is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory. — Wikipedia

I just learn regex in the end of 2020, and today i learn a form validation using RegEx. Here i found a few syntax that really save my time. Hope for you too.

Name Checker

As we know, that most of form has a first and last name on it. Here is the form name validation. The most, important thing below is the number (2,8) it means we will take the validation between 2 until 8, if not, the form will be wrong.


Email Validation

Email is one of important things in this modern time, we use our email to get subscription of a things or many others. But as a developer, i believe sometimes we forget to make validation, so fake user can put wrong value. So with this regex, it can save your time.


Phone Number Validation

Phone number is vital, everyday we always bring smartphone right? So, this simple regex perhaps can help to build a US phone number format. #cmiiw


Zip Number Validation

Zip number is somehow always being in validation email, it used to validate zip code. This is the way i build it, you can follow or edit as you likes


Here is the example output, when using it

Hope it usefull!

Source code for the code above



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store