I have a string that I would like to test to see if it is in the following format.
exactly seven alphabetical OR numerical characters, followed by a '_', followed by
exactly five alphabetical OR numerical characters, followed by a '_', followed by
exactly seven alphabetical OR numerical characters, followed by a '_', followed by
exactly nine alphabetical OR numerical characters.
No other characters should exist other then the above mentioned characters.
I would like a function that returns true if it matches the description or false if it does not match.
Edit: alpha and numeric characters can be mixed.
The
{}will allow you to specify how many times char can be repeated.The
[]lets you list possible characters where-specifies ranges of characters.The
iflag at the end makes it case-insensitive.^marks the start of the string and$marks the end. These prevent anything to be in front of behind of the match.