Regular Expressions in C# - Password Validator Revisited
Sometimes we make life more difficult than it needs to be. Lately, I've learned a little more about Regular Expressions and "Negative Look-Around". I've used it a lot, but it only recently dawned upon me that I was not making full use of it. Case in point, take a look at my earlier regular expression article where I explain how to validate a password with multiple requirements ( Regular Expression Alternations ). This article discusses the absense of the boolean AND in regular expressions and provides a complex IF-THEN-ELSE approach to test a string for conforming to multiple "password" constraints. And my subsequent article ( Regular Expression Double Negatives ) gets more complex with an "inside-out" approach to compensate for the lack of an AND operator. But, let's go back even further to the article where I "explain" Negative Look-ahead . In this article, I provide the simple Negative Look-ahead pattern... “(?!pattern)” ....