It's all about the answers!

Ask a question

Why I am getting different behavior with regular expression in sample text or Eclipse/Web client?

Claudia Callegari (44449771) | asked Jan 11 '13, 2:56 p.m.
I have a string attribute to simulate a floating type (unfortunately, not using 4.0.1 yet).

I have a string custom attribute, and now trying to add a validation using a regular expression.
This field has to contain a number in the 0-100 range, without decimals, or if decimals, up to tenth (up to 2 decimals only).

My expression is:
although I also tried

which works fine in the sample text box, but within a workitem (either Eclipse or Web, let's say at "execution" time), the behavior is not the same, and it does not accept numbers with decimals.
What am I doing wrong?

Accepted answer

permanent link
Filip Wieladek (30413) | answered Jan 14 '13, 12:37 p.m.
Hi Claudia,

Please try the following regex:


The reason for the difference in behaviour is that in the configuration dialog we are using the Java Regular Expressions to test the regex. During attribute validation we actually run the regular expression in javascript on both the eclipse client and web ui (to ensure consistency across the two platforms). 

It seems that the regex implementation in javascript is getting confused. I tried the regex posted in this answer and it works as expected and validates the number correctly.

Claudia Callegari selected this answer as the correct answer

Claudia Callegari commented Jan 15 '13, 4:50 p.m.

Thanks Filip! Don't know why the other one was not working, but this one is pretty fine! Appreciate it.

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.