Quack
asked on
is it possible to set up a regex to validate each position in a string of characters in a form field?
is it possible to set up a regex to validate each position in a string of characters in a form field?
I have a requirement for a contract number field in a Cold Fusion form. Requirements are:
• Positions 1-6 will be the 70Z0XX where XX is the contracting office code IE: 23.
• Positions 7-8 will be the two digit Fiscal Year IE: 17.
• Position 9 will be the one character instrument code IE: C, D, F.
• Positions 10-17 will be agency assigned number.
• New Example: 70Z02317D00000001
Is it possible to set up an expression at different points w/in the string of characters? I've never done that...only length requirements and forcing it to start w/ either a number or a letter. thanks for any help.
I have a requirement for a contract number field in a Cold Fusion form. Requirements are:
• Positions 1-6 will be the 70Z0XX where XX is the contracting office code IE: 23.
• Positions 7-8 will be the two digit Fiscal Year IE: 17.
• Position 9 will be the one character instrument code IE: C, D, F.
• Positions 10-17 will be agency assigned number.
• New Example: 70Z02317D00000001
Is it possible to set up an expression at different points w/in the string of characters? I've never done that...only length requirements and forcing it to start w/ either a number or a letter. thanks for any help.
ASKER
thanks...it validates w/ my checker...I'll let you know...
ASKER
looks as though this should work...thanks
ASKER
Ok...I was wrong...the only validation is that it has to start w/ 70Z0...Z doesn't have to uppercase fyi and the rest of the string can be uppercase letters or numbers up to 22 characters. Would this work?
^[70Zz0][A-Za-z0-9]{1,21}$
^[70Zz0][A-Za-z0-9]{1,21}$
I think you would want more like this.
»bp
^70[Zz]0[A-Za-z0-9]{1,22}$
»bp
ASKER
Ok...back to the original requirments we go...sort of:
New requirements are:
• Positions 1 – 4: ‘70Z0’ or ‘70z0’ where 0 is zero - good to go
• Positions 5 – 6: alphanumeric
• Positions 7 – 8: numeric
• Position 9: alphabetic
• Positions 10 – 17: alphanumeric
so would this work still?:
New requirements are:
• Positions 1 – 4: ‘70Z0’ or ‘70z0’ where 0 is zero - good to go
• Positions 5 – 6: alphanumeric
• Positions 7 – 8: numeric
• Position 9: alphabetic
• Positions 10 – 17: alphanumeric
so would this work still?:
^70Z0\d{4}[CDF]\d{8}$
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry ... out of the country until yesterday...thanks so much for your help Bill!
https://regex101.com/r/o2hdAc/1
Open in new window
»bp