1 Reply Latest reply: May 19, 2013 5:50 PM by Bradtuckett-Oracle RSS

    Regular expression problem

    1009744
      Hi Guru's,

      I'm a newbie to OPA and need to create some regular expressions. However I do not seem to get the basics right. I created an attribute of the type number. I need to validate user input that only makes is possible to enter a value from 0 up to 100 without any decimal points. I therefore used the expression ^((100)|(\d{0,2}))$ When I enter a value of for instance 1. I get the message that 1 is an invalid value. Why is this an invalid value?

      Another one where I do not even understand how to start is that I need to validate that only a value is entered from 0 up to and including 2.250. However the value 0 is not allowed and the user should be able to enter a maximum of 3 decimals.

      Any help is highly appreciated.

      Regards,
      L
        • 1. Re: Regular expression problem
          Bradtuckett-Oracle
          This is an invalid value because it is a number - while minimum and maximum validation occurs on the value that the user enters, the regular expression will be applied to the formatted string representation of the number - in this case, it is "1.0" that is being validated, not "1".

          To validate a number from 0 up to 100 without any decimal points, use the minimum value "0", maximum value "100" and the regular expression:
          ^\d+.0$
          To validate a number greater than 0 up to and including 2.250 with a maximum of 3 decimals, use the minimum value "0.001", maximum value "2.225" and regular expression:
          ^\d+.\d{1,3}$