Exrex is a command line tool and python module that generates all – or random – matching strings to a given regular expression and more. It’s pure python, without external dependencies.
There are regular expressions with infinite matching strings (eg.: [a-z]+), in these cases it limits the maximum length of the infinite parts.
It uses generators, so the memory usage does not depend on the number of matching strings.
Also Read : Sh00t : A Testing Environment for Manual Security Testers
Features
How Installation Is Done?
To install it, simply run the below command:
$ pip install exrex
Or else you can try the below steps to install it
$ easy_install exrex
How to use it?
If it is as python module
import exrex
exrex.getone(‘(ex)r\1’)
‘exrex’
list(exrex.generate(‘((hai){2}|world!)’))
[‘haihai’, ‘world!’]
exrex.getone(‘\d{4}-\d{4}-\d{4}-[0-9]{4}’)
‘3096-7886-2834-5671’
exrex.getone(‘(1[0-2]|0[1-9])(:[0-5]\d){2} (A|P)M’)
’09:31:40 AM’
exrex.count(‘[01]{0,9}’)
1023
print ‘\n’.join(exrex.generate(‘This is (a (code|cake|test)|an (apple|elf|output)).’))
This is a code.
This is a cake.
This is a test.
This is an apple.
This is an elf.
This is an output.
print exrex.simplify(‘(ab|ac|ad)’)
(a[bcd])
Command line usage ?
exrex –help
usage: exrex.py [-h] [-o FILE] [-l] [-d DELIMITER] [-v] REGEX
exrex – regular expression string generator
positional arguments:
REGEX REGEX string
optional arguments:
-h, –help show this help message and exit
-o FILE, –output FILE
Output file – default is STDOUT
-l N, –limit N Max limit for range size – default is 20
-c, –count Count matching strings
-m N, –max-number N Max number of strings – default is -1
-r, –random Returns a random string that matches to the regex
-s, –simplify Simplifies a regular expression
-d DELIMITER, –delimiter DELIMITER
Delimiter – default is \n
-v, –verbose Verbose mode
Examples:
$ exrex ‘[asdfg]’
a
s
d
f
g
$ exrex -r ‘(0[1-9]|1[012])-\d{2}’
09-85
$ exrex ‘[01]{10}’ -c
1024
phpMyAdmin is a free, open-source PHP application that provides a browser-based interface for managing MySQL and…
Zabbix is a mature open-source infrastructure monitoring platform that collects metrics from network devices, servers, virtual…
Gradle is a powerful open-source build automation tool used primarily for Java, Kotlin, Groovy, and Android…
TeamViewer is a proprietary cross-platform remote access application for remote control, desktop sharing, file transfer, and online meetings. It is one of the most widely used remote support tools in the world, available for Windows, macOS, Linux, iOS, and Android. TeamViewer is not included in the Ubuntu repositories because it is proprietary software. This guide covers how to install TeamViewer on Ubuntu 18.04 using the official .deb package. The same steps apply to Ubuntu 16.04, Debian, Linux Mint, and Elementary OS. <strong>Prerequisite:</strong> You need sudo access. Install TeamViewer on Ubuntu: Download the .deb Package Download the official TeamViewer .deb package. The _amd64.deb suffix indicates this package is for 64-bit x86-64 systems. For ARM-based machines, download the appropriate package from the TeamViewer Linux downloads page: bashwget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb Install the package using apt. The ./ prefix tells apt this is a local file path, not a package name from the repositories:…
Nagios is one of the most widely used open-source infrastructure monitoring systems in the world. It…
Laravel is an open-source PHP web application framework built around an expressive, developer-friendly syntax. It is…