Coder Social home page Coder Social logo

Add support for list of regex in regex.json about pywhat HOT 4 OPEN

 avatar commented on May 28, 2024 2
Add support for list of regex in regex.json

from pywhat.

Comments (4)

GauriBodke avatar GauriBodke commented on May 28, 2024

Hi, I would like to know about this issue in detail. Do you want multiple regex patterns separated by vertical pipe ( | ), or do you want any change in the code to support a list of regex patterns?

I can solve this issue by creating following blocks with different regex pattern for different type of phone Number Patterns.

      "Name": "Phone Number",
      "Regex": "^(\\s*(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?\\s*)$",
      "plural_name": false,
      "Description": null,
      "Rarity": 0.5,
      "URL": null,
      "Tags": [
         "Identifiers",
         "Credentials",
         "Phone Number",
         "Phone"
      ],
      "Children": {
         "path": "phone_codes.json",
         "entry": "Location(s): ",
         "method": "hashmap"
      },
      "Examples": {
         "Valid": [
            "202-555-0178",
            "+1-202-555-0156",
            "+662025550156",
            "+356 202 555 0156"
         ],
         "Invalid": []
      }
   }```

from pywhat.

 avatar commented on May 28, 2024

I would like to have a list of regexp, so yes, changes in code are needed. Pywhat should concatenate all these regexes into one using pipes(|). Therefore, only regex loader function should be updated.

from pywhat.

GauriBodke avatar GauriBodke commented on May 28, 2024

Hey, I am able to combine regex patterns dynamically using |. What is your suggestion for combining other parameters of the block, such as Description, Rarity, URL, Tags, Children, and Examples.

from pywhat.

amadejpapez avatar amadejpapez commented on May 28, 2024

Hi! I will take our THM flag regex to better show what we want to achieve. (The only part changed is Regex)

We want to separate multiple regex formats of one identifier into a list of regexes, instead of having all of them together and separated by |. Some of regexes are quite long and seeing where is what is getting harder, so our goal is to improve their readability.

I am not sure how PyWhat should use them after tho. Merged them back into one with | or search with each regex separately. Probably the latter.

I hope this clears some things. Maybe @bee-san has some more suggestions. :)

   {
      "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": []
      }
   }

from pywhat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.