Regex Crash Course: Lookahead and Password Validation

Rawisglenn
4 min readOct 20, 2023
Photo by Jordan Bigelow on Unsplash

Learn by diving deep into the abyss

If time permits, it is good to learn regex from scratch. However, that is often not the case as tech evolves at a rapid speed and there are too many things to excel at. That’s why I prefer to just dive deep into real world example. In this scenario, we will work with a common feature in most web app, validation of the password field.

Why validate password with regex?

There are many popular validation libraries out there especially for modern web framework such as Yup on react apps. As form builder library like formik recommends validation library like Yup in their documentation. Since the UI component is geared for it, why not use it!

Though there is validation of data on the frontend, as long as the API exists, it is still possible to use it with other frontends or even postman. Hence there should be validation at the backend for security and data integrity. For that purpose, the validation could be more robust and comprehensive than the frontend, hence it is good to write our own validation. Also, let’s try to keep the backend small, by not installing so much libraries.

Regex Pattern for Password Validation

--

--

Rawisglenn

Please help to follow me, I will follow back! Tech is fun, join in the fun! Web Dev x Hackathon x Agile Project Management x Medium Writer Tips *no paywall