I need a RegEx pattern which will be sent by the client where the starting characters will be alphanumeric, the length of this starting String will be defined by the number after this String. This is followed by a special character which will always be a single character. This is again followed by a variable length string of alphanumeric characters.
I have come closest to the below String and formats.
[A-Za-z0-9]{4}-[A-Za-z0-9]{5} - RegEx Input String
[A-Za-z0-9]{2}#[A-Za-z0-9]{6} - RegEx Input String
[0-9]{3}#[0-9]{5} - RegEx Input String
[a-z]{5}#[a-z]{5} - RegEx Input String
[A-Z]{4}#[a-z]{4} - RegEx Input String
[\w]{\d{1,1}}(\S{1,1})[\w]{\d{1,1}} - RegEx Format
Is the above pattern and format correct?
Can we validate the RegEx input string against the required RegEx format?
This is a web service which will have an input as [A-Za-z0-9]{4}-[A-Za-z0-9]{5}. I need two things here. First, how do I validate this input to see if it matches the format I want and the proceed. The format is the one I mentioned above as RegEx format.