You are viewing limited content. For full access, please sign in.

Question

Question

field constraints

asked on May 11, 2015

I have a field constraint of \w{2}-\d{2}-\d{3}-\d{2}-\d|\w{2}-\d{2}-\d{3}-\d{2}-\w\d to control field entries that should look like this:  NE-33-042-12-W4

I realize now that the first part (the "NE") could sometimes need to be just N.  So I researched regular expressions and saw that I should be able to use "\w{1,2}" to control allowing one or two characters.  I tried it but it doesn't work.

Could someone tell me what I should enter to make it allow 1 or 2 characters?

Thx, Connie

0 0

Answer

SELECTED ANSWER
replied on May 11, 2015

Your constraint is a "Format 1 OR Format 2" constraint (the "|" in the middle stands for "or"). So it should be \w{1,2}-\d{2}-\d{3}-\d{2}-\d|\w{1,2}-\d{2}-\d{3}-\d{2}-\w\d if you want both to allow 1 or 2 letters at the beginning of the string.

1 0

Replies

replied on May 11, 2015

\w{1,2}-\d{2}-\d{3}-\d{2}-\w\d works for me. What exactly doesn't work for you? Did you add the \w{1,2} to both regular expressions in your constraint?

0 0
replied on May 11, 2015

If \w{1,2} does not work for you, then you could probably use \w?\w

0 0
replied on May 11, 2015

I just tried again, and tried Bert's suggestion of \w?\w and neither worked, so I tried saving the changes, closing out of everything and going back in to see if the change would take.  Nope.  Miruna, what do you mean with "Did you add the \w{1,2} to both regular expressions in your constraint?".  I'm only aware of one place to make the change.

Thx, Connie

0 0
SELECTED ANSWER
replied on May 11, 2015

Your constraint is a "Format 1 OR Format 2" constraint (the "|" in the middle stands for "or"). So it should be \w{1,2}-\d{2}-\d{3}-\d{2}-\d|\w{1,2}-\d{2}-\d{3}-\d{2}-\w\d if you want both to allow 1 or 2 letters at the beginning of the string.

1 0
replied on May 11, 2015

That was it, Miruna!  I had forgotten there were two parts to this expression allowing for another variation.  I see now that this \w{1,2} could have been used for the variation on the end of the expression, as well; instead of what I had originally settled with for that piece.

Thanks!

Connie

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.