Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Regex Validations

Regular Expression or (Regex) is one of the foremost effective, adaptable, and proficient content preparing approaches. Regex has its possess wordings, conditions, and sentence structure; it is, in a sense, a scaled down programming language.

example:-

This regex is use for Phone number validation

/^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/;

This simple regular expression just checks for 2 digits / 2 digits / 4 digits date format

/^\d{2}\/\d{2}\/\d{4}$/

Complex regex for date

/^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/

If you want to allow only alphanumeric characters, use this regular expression:

/^[a-zA-Z0-9]*$/

Decimal Numbers For decimal numbers with one decimal point, the regular expression is:

/^[0-9]+\.?[0-9]*$/

If you want to allow only Standard email address

/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

If you want supports alphabets and numbers no special characters except underscore(‘_’) min 3 and max 20 characters

/^[A-Za-z0-9_]{3,20}$/;

If you want your password supports special characters and here min length max 20 charters only

/^[A-Za-z0-9!@#$%^&*()_]{6,20}$/;

Related Posts

Exploring and Creating a Proof of Concept (POC) to Upload APK Directly from GitHub Package

Automating the process of uploading an APK (or AAB) to the Google Play Store from GitHub can significantly speed up your CI/CD pipeline. By integrating Google Play’s…

A Detailed Guide to CI/CD with GitHub Actions

Continuous Integration (CI) and Continuous Deployment (CD) are modern software development practices that automate the process of integrating code changes, running tests, and deploying applications. With the…

Step-by-Step Guide for Setting Up Internal Testing in Google Play Console

1. Understanding the Types of Testing Before uploading your Android app for internal testing, it’s essential to know the differences between the testing options available in Google…

The Complete 2025 Guide to GitLab Training, Certification, and Expert Trainers

Level Up Your DevOps Career: The Complete 2025 Guide to GitLab Training, Certification, and Expert Trainers Introduction to GitLab: The Backbone of Modern DevOps As businesses accelerate…

Site Reliability Engineering (SRE) Foundation Certification

Introduction to Site Reliability Engineering (SRE) Foundation Certification The Site Reliability Engineering (SRE) Foundation certification is an industry-recognized credential designed to provide students with a comprehensive understanding…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x