-
-
Notifications
You must be signed in to change notification settings - Fork 382
Create "regex within regex" for subcategories #51
Copy link
Copy link
Closed
Description
Some regex have sub-categories, for example:
- Mastercard numbers -- the first 4 digits represent what company that card belongs to.
- Phone numbers. If they start with +44 or 07, it's the UK!
As such, I propose we change our code into:
{
"Name": "MasterCard Number",
"Regex": "^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$",
"plural_name": false,
"Description": null,
"Rarity": 0.5,
"Tags": [
"Credit Card",
"Finance"
],
"Children": [
{
"Name": "BarclayCard",
"Regex:" "5117.*"
Same value as the parent above
}
]
},We want to keep the same object for each child in case we have anything special to add like a website or a cool description etc. It doesn't cost us much to do this, but it is helpful!
Also, our regex for the children can be much broader. Read it as:
- When I pass the mastercard regex
- When I pass the barclaycard regex (which just checks to see if the first few numbers are equal to 5117)
- Return
Because the children only run when the parents do, the child regex can be lighter.
As an aside, Mastercard have very helpfully provided a CSV table of all the companies and what their Mastercard subrange is:
https://www.mastercard.us/en-us/business/issuers/get-support/simplified-bin-account-range-table.html
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels