Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternating Number and Alpha pattern #153

Open
jayiconcmo opened this issue Oct 27, 2016 · 0 comments
Open

Alternating Number and Alpha pattern #153

jayiconcmo opened this issue Oct 27, 2016 · 0 comments

Comments

@jayiconcmo
Copy link

Here are the rules for my string and would like to see what methods I need to use that would work with this library.

  1. Must be LNLNLN where L = letter and N = number. So for example A8B9L7 would be valid but AA88HH would not be.
  2. Must be 6 digits only.
  3. Must not have a Z or W in the first position but they are okay in the other positions.
  4. Can not have D,F,I,O,Q,U, letters in any position.
  5. I would pass an upper case version of the letter to the function to verify so only A-Z apply and doesn't need case sensitivity.
  6. Must give true if it passes all of these.

Now if I pass
899098 - should fail
Z9F0N8 - should fail because of the Z in first position
W9F0N8 - should fail because of the W in first position.
V9F5L2 - should fail because of the F - not allowed anywhere - includes the D,I,O,Q, and U letters as well.
V9H7 - should fail - not long enough
C0T0R6V - should fail because it is too long.
1G2G3G - should fail - numbers and letter are not in the right places.

A9Z6J8 - this should pass as Z is not in the first position. Same for W.
M8K8E6 - Should pass

The current alternating pattern I'm using is /^[A-Z][0-9][A-Z][0-9][A-Z][0-9]+$/.test(value)
however I have to say that I have a lot of pre-processing that I'm doing before it gets there - ie turning to uppercase, ensuring Z and W is not in the first position, removing all non alphanumeric stuff along with non valid letters,, and so on. Just including it here as it may help.

May have to break things up into two separate calls to verbal expressions if that would work better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant