ScaryEders
Programmer
I'm wanting to create a perl sub called "checkValid". When I use this sub, I want to be able to pass to two string values to it and for it use perl's RegEx abilities to return a true or false response. However, I'm not too knowledgeable when it comes to RegEx, which is why I'm asking for your help in making my sub.
The two strings to be passed to checkValid() will be in the form:
checkValid($variableToCheck, 'typeToCheck')
'typeToCheck' could be the value 'email', 'url', 'filename', 'username', or 'password'. The function of checkValid() will be to return whether the $variableToCheck is a valid form of the ‘typeToCheck’.
I want to define each of the ‘types’ as follows:
email: (letters, numbers, fullstops, and underscores only)(the symbol ‘@’)(letters, at least one fullstop and numbers only)
url: (letters, numbers, at least one fullstop, underscores, dollar signs, forward slashes, hyphens, wiggly hyphens, plus signs, exclamation marks, asterisks, brackets and commas only)
filename: (letters and numbers only)
username: (letters, numbers and underscores only)
password: (letters, numbers and spaces only)
Any help in creating my sub would be much appreciated!
- Ed Jones
The two strings to be passed to checkValid() will be in the form:
checkValid($variableToCheck, 'typeToCheck')
'typeToCheck' could be the value 'email', 'url', 'filename', 'username', or 'password'. The function of checkValid() will be to return whether the $variableToCheck is a valid form of the ‘typeToCheck’.
I want to define each of the ‘types’ as follows:
email: (letters, numbers, fullstops, and underscores only)(the symbol ‘@’)(letters, at least one fullstop and numbers only)
url: (letters, numbers, at least one fullstop, underscores, dollar signs, forward slashes, hyphens, wiggly hyphens, plus signs, exclamation marks, asterisks, brackets and commas only)
filename: (letters and numbers only)
username: (letters, numbers and underscores only)
password: (letters, numbers and spaces only)
Any help in creating my sub would be much appreciated!
- Ed Jones