Add support for list of regex in regex.json#244
Add support for list of regex in regex.json#244GauriBodke wants to merge 1 commit intobee-san:mainfrom
Conversation
|
@GauriBodke Good work. My reviewThe author proposed a new way to improve the readability of regex.json This PR will merge the two entries of Regexps with the same name. Then the old Regexps that have the subpattern joining with '|' need to split into multiple entries. [
{
"Name": "TryHackMe Flag Format",
"Regex": "(?i)^thm{.*}|tryhackme{.*}$",
"plural_name": false,
"Description": "Used for Capture The Flags at https://tryhackme.com",
"Rarity": 1,
"URL": null,
"Tags": [
"CTF Flag"
],
"Examples": {
"Valid": [
"thm{hello}"
],
"Invalid": []
}
}
]New regex.json [
{
"Name": "TryHackMe Flag Format",
"Regex": "(?i)^thm{.*}$",
"plural_name": false,
"Description": "Used for Capture The Flags at https://tryhackme.com",
"Rarity": 1,
"URL": null,
"Tags": [
"CTF Flag"
],
"Examples": {
"Valid": [
"thm{hello}"
],
"Invalid": []
}
},
{
"Name": "TryHackMe Flag Format",
"Regex": "(?i)^tryhackme{.*}$",
"plural_name": false,
"Description": "Used for Capture The Flags at https://tryhackme.com",
"Rarity": 1,
"URL": null,
"Tags": [
"CTF Flag"
],
"Examples": {
"Valid": [
"thm{hello}"
],
"Invalid": []
}
}
]This is different from the method proposed by @amadejpapez that uses list as the value of "Regex" key. {
"Name": "TryHackMe Flag Format",
"Regex": ["(?i)^thm{.*}$", "(?i)^tryhackme{.*}$"],
"plural_name": false,
"Description": "Used for Capture The Flags at https://tryhackme.com",
"Rarity": 1,
"URL": null,
"Tags": [
"CTF Flag"
],
"Examples": {
"Valid": [
"thm{hello}"
],
"Invalid": []
}
}My opinionThis PR did fix the author's issue about readability. However, the main drawback is that |
|
I agree. Having @GauriBodke Sorry if this wasn't clear enough from the start and if my comment with the example was too late. If you could change your PR to that, it would be amazing :) You can take the THM regex list from my example and update PyWhat to work with it. Then I can go through the database and separate more regexes into lists. |
⚠ Pull Requests not made with this template will be automatically closed 🔥
Prerequisites
Why do we need this pull request?
regex.jsonare combined dynamically , which makes individual regex easy to understand. Here for example , there can be different types of Phone Number pattern such as 10 digits, 7 digits or 11 digits; so we can have multiple entries with same Name and different regex pattern. The added code will dynamically combine such entries by vertical pipe|.What GitHub issues does this fix?
Copy / paste of output