1

I have a task to validate xml messages through Drools implementation in Java.

In a particular drool implementation I am asked to validate a field through n..5 format.

I am using regex for format checking like:

SampleText.matches("[0-9]") 

For the n..5 It means the field max length is 5 'digits'? Or it means that the field has to be always 5 digits in length?

I assume that it has to do with the max length is it right?

Merry Christmas and sorry for the dumb question Thank you in advance

Haim Raman
  • 11,508
  • 6
  • 44
  • 70

1 Answers1

0

To specify the exact number of characters/digits you can use {}, i.e.:

SampleText.matches("\d{5}") // matches 5 digits
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
  • 1
    Thank you Pedro that is what I was searching for . Specification team explained the requirement of the validation in a poor way. That's exactly what I needed . Merry Christmas – user10832149 Dec 25 '18 at 15:49