Skip to content

Instantly share code, notes, and snippets.

View mhgarry's full-sized avatar

Matthew Garry mhgarry

View GitHub Profile
@mhgarry
mhgarry / Regex.md
Last active September 1, 2024 00:59
Let's Learn Some Regex!

Fortify Your Web Application: Building a Strong Password Validation Regex for User Security

Summary

Regular expressions (regex) are an excellent tool for implementing robust verification and security measures in web applications involving user input or sensitive data. Specifically, regex can be used to search for patterns in strings, determining whether they match the desired format. This is particularly valuable when registering a user in a web application's database to ensure they meet the required security standards.

In this example, the regex will validate that a string is not empty, contains a lowercase letter, an uppercase letter, a number, and a special character. Additionally, it ensures that the string is between 8 and 32 characters in length. If the string matches these criteria, the user is registered in the web application. Otherwise, the user will be prompted to create a password that meets the requirements.

There are several reasons why this is useful for user registration in a web app