GithubHelp home page GithubHelp logo

regxy's Introduction

regxy

Python module for making regex painless.

Operations Supported

  • Match everything between two texts
  • Extract emails
  • Extract phone numbers

Installation

You can install it using pip as follows:

pip install regxy

or you can clone this repo for favoring portability:

git clone https://github.com/UltimateHackers/rexgy/

Usages

grab

Lets say there's website which generates a random password when you visit it. By looking at the source code, you find this:

This is your random password: <span color="red" id="pass">puSSySlay3r</span>. Enjoy!

Now you want to write a program which can visit the website can and can return you the generated password. In that case, you can use regxy as follows:

from regxy import grab
password = grab(string, 'id="pass">', '</span>')
print password

Output

puSSySlay3r

The syntax is following:

grab(string, start, end)

Where string is the string you want to process, start and end are the texts within which your infromation of interest lies.
In this case your string is the source code of the website which can be extracted by other modules.

graball

Lets say there's a website which has a list of proxies and you want to write a program to extract those proxies. The source code is something like:

<td class="dark">127.0.0.1:80</td>
<td class="dark">127.0.0.2:8080</td>
<td class="dark">127.0.7:80</td>
<td class="dark">127.255.255.255:80</td>

In this case, you can use the graball function which returns all the matches unlike grab which only returns one. The syntax is as same as the grab function but it returns a list and not a string.

from regxy import graball

grab(string, 'dark">', '</td>')

emails

As the name suggest, this function can extract emails from a given string with 99.99% accuracy. Usages:

from regxy import emails
emails(string)

It returns a list of matches.

numbers

This function can extract phone numbers from a given string. Usages:

from regxy import numbers
numbers(string)

It returns a list of matches.

What if there's no match?

Well in that case all the functions return False.

Cheat Sheet

Function Syntax Output
grab grab(string, start, end) string
graball grab(string, start, end) list
emails emails(string) list
numbers numbers(string) list

License & Contribution

Contributions are heartly welcome, doesn't matter if they are bug reports, pull requests or ideas to make regxy better.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

regxy's People

Contributors

s0md3v avatar

Watchers

 avatar

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.