user2758757
user2758757

Reputation: 109

validate coordinate using regex

I want to validate column in oracle database of type NUMBER(5,2) using regex, I have tried but it not work correctly as required manner, this restricted validation needed in regex:

REGEX: [-+]?\\d{0,3}\\.?\\d{0,2}+

  1. 999 valid
  2. 9999 invalid
  3. -999.99 valid
  4. -999. invalid
  5. 999.9 valid

Upvotes: 0

Views: 57

Answers (1)

MDEV
MDEV

Reputation: 10838

This works as expected for the cases you've provided:

^[-+]?\d{1,3}(\.\d{1,2})?$

If you have problems with it, let me know what cases it fails on (and if possible a worded description of what should be matched)

Upvotes: 2

Related Questions