Bill Chappell
Bill Chappell

Reputation: 311

Python valid values?

I am trying to fix older code someone wrote years ago using python. I believe the "\d\d\d\d" refers to the number of text characters, and 0-9A-Z limits the type of input but I can't find any documentation on this.

idTypes = {"PFI":"\d\d\d\d",
       "VA HOSPITAL ID":"V\d\d\d",
       "CERTIFICATION NUMBER":"\d\d\d-[A-Z]-\d\d\d",
       "MORTUARY FIRM ID":"[0-9]",
       "HEALTH DEPARTMENT ID":"[0-9]",
       "NYSDOH OFFICE ID":"[0-9]",
       "ACF ID":"AF\d\d\d\d",
   "GENERIC NUMBER ID":"[0-9]",
       "GENERIC ID":"[A-Za-z0-9]",
       "OASAS FAC":"[0-9]",
       "OMH PSYCH CTR":"[0-9A-Z]"}

Like the PFI values seem to be limited to 4 numeric digits in a string field, so 12345 doesn't work later in the code but 1234 does. Adding another \d doesn't appear to be the answer.

Upvotes: 0

Views: 408

Answers (1)

Błotosmętek
Błotosmętek

Reputation: 12927

These are, apparently, regular expressions used to validate inputs. See https://docs.python.org/2/library/re.html

Without seeing the code that uses these values it is impossible to say more.

Upvotes: 2

Related Questions