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

How to Generate a GitHub OAuth Token with Read/Write Permissions for Private Repositories

When working with GitHub, you may need to interact with private repositories. For that, GitHub uses OAuth tokens to authenticate and authorize your access to these repositories….

Laravel Error: Target class [DatabaseSeeder] does not exist – Solved for Laravel 10+

If you’re working with Laravel 10+ and run into the frustrating error: …you’re not alone. This is a common issue developers face, especially when upgrading from older…

JWT (JSON Web Token) vs OAuth 2.0

Both JWT and OAuth 2.0 are used for managing authentication and authorization, but they serve different purposes and work in distinct ways. 1. Purpose: 2. Role: 3….

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…

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