Garrett Fitzgerald wrote:
> On 11/1/07, Paul Newton <[EMAIL PROTECTED]> wrote:
>> Hi all
>>
>> I need to check an input value against the following criteria
>>
>> 1. Length 1 - 10 characters
>> 2. Each character may be either "C" or "N"
>> 3. All C's must be in a group, so CCNNC would be invalid
>> 4. All N's must be in a single group (as above)
>> 5. Can be all C's
>> 6. Can be all N's
>> 7. Can be x C's followed by y N's
>> 8. Can be x N's followed by y C's
>> 9. 1 <= x+y <= 10 (same as 1 above, really)
>
I think this will do it :
^(?!.{11,})(?:(?:C{0,10}N{0,10})|(?:N{0,10}C{0,10}))$
Explanation : matches a beginning of string not followed by 11 or more
characters (that would be up to 10 characters total string length) and
then either none to 10 C's followed by none to 10 N's or none to 10 N's
followed by none to 10 C's.
HTH
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.