This shows how to use a Regular expression to break your string into parts then check each part for the number condition. Line 8 says "I need 1 capital letter, followed by optional (the *) lower case letters followed by optional numbers". Line 14 checks if the last character in each section is a number, and if not add "1" to our string.