thanks bart for ur reply
ur code is fine....but actually my problem of pattern matching includes 31(or less) instead of the 4(or less) pairs that as i mentioned in my post. i made the change so as to be able to give an example easily.
if i follow ur code pattern then it might turn out to be a bit too long......any shorter version???
thanks again for ur help so far
vineet