Home > OS >  RUC Paraguayan validator
RUC Paraguayan validator

Time:09-01

I want to make a validation for RUC from Paraguay. Now y can validate this expression ^[0-9 #-]*$ and got this result 1234567-8, but I also have to validate this values 1234567 -> only numbers 1234567A-8 -> number follows by a only one letter follow by -8

CodePudding user response:

You can use

^[0-9] [A-Z]?(-[0-9])?$

See the regex demo.

Details:

  • ^ - string start
  • [0-9] - one or more digits
  • [A-Z]? - an optional uppercase ASCII letter
  • (-[0-9])? - an optional sequence of a - and a digit
  • $ - end of string.
  • Related