How to edit the 'Ignore Patron Barcode' REGEX code for TBS Portal
NOTE: Any change made requires the TBS ILS SERVICE to be restarted.
By default, we have the following examples in the TBS Portal:
Numberical Only:
patronBarcode=^[0-9]{1,}\z
Alphanumeric Only:
patronBarcode=^[A-Za-z0-9]{1,}\z
Standard Ascii:
patronBarcode=^[\x00-\x7B]{1,}\z
If you want to take it one step further, use CHATGPT to ask "how to creat a regex for XXXXXXX"
For example, I want numeric-only cards plus a 'computer-only' card that starts with PACREG. Here is what I got:
QUESTION:
How to I create a regex for numeric only, but also allow pacreg and case-insensitive?
ANSWER:
To create a case-insensitive regex that allows only numeric values or the word "PACREG" (in any case), use the following regex:
(?i)^pacreg$|^\d+$
Breakdown:
(?i)→ Case-Insensitive Flag- Makes
"PACREG"case-insensitive, allowing"PACREG","pacreg","PacReg", etc.
- Makes
^pacreg$^→ Ensures the match starts at the beginning of the string.pacreg→ Matches the exact word"pacreg"(case-insensitive).$→ Ensures the match ends at the end of the string.- Matches: ✅
"PACREG","pacreg","PaCrEg"
|→ OR Condition- Separates the two valid patterns:
- Pattern 1:
"PACREG"(case-insensitive) - Pattern 2: Only numbers
- Pattern 1:
- Separates the two valid patterns:
^\d+$^→ Ensures the match starts at the beginning of the string.\d+→ Matches one or more numeric digits (0-9).$→ Ensures the match ends at the end of the string.- Matches: ✅
"123","45678","0"
What This Regex Allows:
✅ "PACREG"
✅ "pacreg"
✅ "PaCrEg"
✅ "123"
✅ "4567"
What It Doesn't Allow:
❌ "ABC" (not "PACREG" and not numeric)
❌ "pacreg123" (numbers not allowed after "PACREG")
❌ "pacreg 123" (space not allowed)
❌ "12pacreg34" (letters in between numbers)