static final Pattern EXAMPLE_PATTERN = ~/[A-Z0-9\[][A-Z0-9&\/][A-Z0-9]{1,4}/
This is a regex I was given and I am struggling to understand what exactly it limits. Thanks!
static final Pattern EXAMPLE_PATTERN = ~/[A-Z0-9\[][A-Z0-9&\/][A-Z0-9]{1,4}/
This is a regex I was given and I am struggling to understand what exactly it limits. Thanks!
[A-Z0-9\[] means a character that is an uppercase letter, a number, or [[A-Z0-9&\/] means a character that is an uppercase letter, a number, & or /[A-Z0-9]{1,4} means one to four characters that is are an uppercase letter, or a numberSo AA0000 will match. As will A[9 and F/1234
But aaa wont. Nor will AA
[A-Z0-9\[] # Single character, of class A-Z or 0-9 or [
[A-Z0-9&/] # Single character, of class A-Z or 0-9 or & or /
[A-Z0-9]{1,4} # 1 to 4 characters, of class A-Z or 0-9