Regular expression for validating special characters from dating to being in a relationship

If I want to match a line with at least 1 lowercase character then I can use: The part that makes this all interesting is that you can combine any number of assertions about the string into one larger expression that will create your rules for complexity.

So if you want to match a string at least 6 characters long, with at least one lower case and at least one uppercase letter you could use something like: I’m Geoff Lane and I write as I figure things out about software development in the hopes that it can help other people facing similar situations.

Regular Expressions are both complex and elegant at the same time.

They can be made to look like someone was just randomly hammering on their keyboard.

What if we need to support (123) 555-1212 and just 555-1212? The key to making password strength validation easy using Regular Expressions is to understand Zero-width positive lookahead assertions (also know as zero-width positive lookaheads). Luckily the concept itself is a lot simpler than the name.

Knowing that these make assertions about elements in a string, but not about a match itself, you need to combine this with a matching regular expression to create you match validation. With what you know about Zero-width positive lookahead assertions now you can combine a “match everything” with assertions about that line to limit what is matched.Also as a thanks to the larger web community for all of the information and knowledge that they have shared.Rather than returning a match though, it merely returns true or false to say if that match exists. The general form of this is: Now that you know how to make assertions about the contents of a string without actually matching on that string, you can start deciding what you want to actually assert.Remember that on their own these lookaheads do not match anything, but they modify what is matched.

They are also an incredibly efficient and elegant solution to describing the structure of text and matching those structures.They are very handy for defining what a string should look like and as such are very good for use in data validation.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>