i need to match an expression for ID could be 88903 5 digit or 99892A 5 digit with letter [A-G] or 88987-1 5 disgit with letter dash [1-5] with confition IF
like this
if (IDentity-match“(^\d{5}[A-G]$)”-or“(^\d{5}[A-G]-[1-5]$)”)) is my syntax correct ?
If I understand correctly, you have three formats to match:
12345
12345A
12345A-1
Unless you specifically need to exclude letters beyond G, and/or numbers larger than 5 after the dash, you can match all of those with 1 regex string:
\d{5}\W?-?\d?
You can avoid any OR statements.
But also, if all of your ID numbers have the initial 5 digits, and you don’t need to exclude ID numbers with more than 5 digits, the only part you really need is this:
\d{5}
This will match every string that contains 5 numbers in a row, which will still include your values that have extra stuff on the end.
What does the rest of the ID number data set look like? What do you need to NOT match?
Also, if IDentity is a variable that contains the numbers you want to match, you need to call it with a $ like this: