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

Question

Question

field constraints required

asked on October 13, 2014

Requirement:

First four letter numeric next two letter alpanoumeric - next two letter alphanumeric than - all letter numberic.

e.g 2014US-123455

can u suggest field constraint for above requirment.

0 0

Answer

APPROVED ANSWER
replied on October 13, 2014

I'm a little uncertain of your particular pattern, and you don't specify if the numeric component has a specific length, so I'll give you one that would work assuming the length might vary (1 or more numeric digits).

Try: \d{4}\w{2}-\w{2}\d+

I used the \d character class to represent any numeric digit, and the \w character class for a "word character", which in most regular expressions is any letter, number, or the underscore "_" character. If you don't want the underscore, you'll have to replace each \w with [a-zA-Z0-9]

Take a look here for more info:

http://www.regular-expressions.info/shorthand.html

1 0

Replies

replied on October 14, 2014

If by alphanumeric, you mean that it can be either letters of numbers, then I believe that Scott's constraint should work just fine.  If this doesn't work for you, please respond with more details and we'll take another look.

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

Sign in to reply to this post.