^(?![\\s\\S]*(\\d{16})|[\\s\\S]*(\\d{9}))[\\s\\S]*
The above regex does not allow a number greater than 10 digits in the string.
Example, if user enters test 1234567891. The text is a valid text. We should allow user to enter this text.
The user should only not enter a 9 digit number or a 16 digit number.
Example, test 123456789 should be invalid. How to modify the regex.
Don’t use a regex for this kind of check. Java has
.length()on strings: