dimanche 9 avril 2023

Pattern, ignore '&' and subsequent characters if they contain any specific characters

Example, I have 3 String:

String A = "&aHi"; // true, 2 characters in total
String B = "Hi"; // true, 2 characters in total
String C = "Hi!"; // false, 3 characters in total

When the string contains "&" followed by some character like "[0-9A-FK-ORX]" I want it to be excluded in the check if the string is less than 3 characters or greater than 15 characters.

This is what I currently have: Pattern:

"^(?i)(?:(?!&[0-9A-FK-ORX]).|^.{0,2}|^.{16,})$"

but I can't get it to work, I'm trying to get it to ignore lower and upper case, I'm checking that it's less than 3 or greater than 15, but I can't get what I need.

Aucun commentaire:

Enregistrer un commentaire