It's all about the answers!

Ask a question

Error in using validator`s for string validation.

Surender Biyyala (403548) | asked Dec 03 '14, 6:19 a.m.
 Hi ,

I created a validator using the regular expression which should allow either

00000000 or 00000000-00 as below

when test using the test filed it is working fine but the real thing is not working as expected , i mean the attribute which is using this validator is allowing only the 00000000 as the correct value.

Could some please help me in understanding this issue?


One answer

permanent link
Brian Fleming (1.6k11928) | answered Dec 03 '14, 10:28 a.m.
I don't have an explanation as to why, but reversing your expression works for me:

Surender Biyyala commented Dec 03 '14, 12:34 p.m.

Thanks Brain for your help.

I have one more requirement 

i.e.,  My regular expression should allow the following pattern
00000000 or 00000000-00 seperated by ;

the  expression working very fine for the pattern but it is accepting even without the special character. 


How can I force to have the special character between two formats?


Brian Fleming commented Dec 03 '14, 2:43 p.m.

RegEx questions probably don't belong in this forum and you may get better responses somewhere like stackoverflow.  In any case, this
works for me.  No guarantees that there aren't more efficient ways to accomplish the same thing.

Manoj Panda commented Dec 27 '18, 10:59 a.m.

could you please help me in case i want the validation should be MMM-YYYY format. what should  be the regular expression?

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.