All Projects → Xion → unmatcher

Xion / unmatcher

Licence: BSD-2-Clause license
Regular expressions reverser for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to unmatcher

Grex
A command-line tool and library for generating regular expressions from user-provided test cases
Stars: ✭ 4,847 (+18542.31%)
Mutual labels:  regex, regular-expressions
moar
Deterministic Regular Expressions with Backreferences
Stars: ✭ 19 (-26.92%)
Mutual labels:  regex, regular-expressions
Fancy Regex
Rust library for regular expressions using "fancy" features like look-around and backreferences
Stars: ✭ 199 (+665.38%)
Mutual labels:  regex, regular-expressions
Nim Regex
Pure Nim regex engine. Guarantees linear time matching
Stars: ✭ 136 (+423.08%)
Mutual labels:  regex, regular-expressions
simplematch
Minimal, super readable string pattern matching for python.
Stars: ✭ 147 (+465.38%)
Mutual labels:  regex, regular-expressions
Regex
An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.
Stars: ✭ 2,125 (+8073.08%)
Mutual labels:  regex, regular-expressions
Rverbalexpressions
💬 Create regular expressions easily
Stars: ✭ 245 (+842.31%)
Mutual labels:  regex, regular-expressions
Inferregex
Infer the regular expression (regex) of a string 🔤 🔢 🔍
Stars: ✭ 41 (+57.69%)
Mutual labels:  regex, regular-expressions
url-regex-safe
Regular expression matching for URL's. Maintained, safe, and browser-friendly version of url-regex. Resolves CVE-2020-7661 for Node.js servers.
Stars: ✭ 59 (+126.92%)
Mutual labels:  regex, regular-expressions
Ruby Regexp
Learn Ruby Regexp step by step from beginner to advanced levels with plenty of examples and exercises
Stars: ✭ 79 (+203.85%)
Mutual labels:  regex, regular-expressions
Proposal Regexp Unicode Property Escapes
Proposal to add Unicode property escapes `\p{…}` and `\P{…}` to regular expressions in ECMAScript.
Stars: ✭ 112 (+330.77%)
Mutual labels:  regex, regular-expressions
tokenquery
TokenQuery (regular expressions over tokens)
Stars: ✭ 28 (+7.69%)
Mutual labels:  regex, regular-expressions
Youtube Regex
Best YouTube Video ID regex. Online: https://regex101.com/r/rN1qR5/2 and http://regexr.com/3anm9
Stars: ✭ 87 (+234.62%)
Mutual labels:  regex, regular-expressions
Npeg
PEGs for Nim, another take
Stars: ✭ 163 (+526.92%)
Mutual labels:  regex, regular-expressions
Ore
An R interface to the Onigmo regular expression library
Stars: ✭ 54 (+107.69%)
Mutual labels:  regex, regular-expressions
Regex For Regular Folk
🔍💪 Regular Expressions for Regular Folk — A visual, example-based introduction to RegEx [BETA]
Stars: ✭ 242 (+830.77%)
Mutual labels:  regex, regular-expressions
Py regular expressions
Learn Python Regular Expressions step by step from beginner to advanced levels
Stars: ✭ 770 (+2861.54%)
Mutual labels:  regex, regular-expressions
Verbalex
A library for creating complex, composable regular expressions with the reader & writer in mind. 🔍
Stars: ✭ 26 (+0%)
Mutual labels:  regex, regular-expressions
ChatControl-Pro
The ultimate chat solution. Prevent spam, ads, swears and even bots on your server. Replaced by ChatControl Red: https://mineacademy.org/chatcontrol-red
Stars: ✭ 65 (+150%)
Mutual labels:  regex, regular-expressions
expressive-ts
A functional programming library designed to simplify building complex regular expressions
Stars: ✭ 78 (+200%)
Mutual labels:  regex, regular-expressions

unmatcher

unmatcher tries to solve the following problem:

Given a regular expression, find any string that matches the expression.

Why? Mostly just because. But one possible application is to generate test data for string processing functions.

Status

PyPI package version License Build Status

Most typical elements of regexes are supported:

  • multipliers: *, +
  • capture groups: |, ( ) (including backreferences)
  • character classes (\d|\w|\s etc.) and character sets ([])

API

unmatcher module exposes a single reverse function. It takes a regular expression - either in text or compiled form - and returns a random string that matches it:

>>> import unmatcher
>>> print unmatcher.reverse(r'\d')
7

Additional arguments can be provided, specifying predefined values for capture groups inside the expression. Use positional arguments for numbered groups ('\1', etc.):

>>> import unmatcher
>>> print unmatcher.reverse(r'<(\w+)>.*</\1>', 'h1')
<h1>1NLNVlrOT4YGyHV3vD7cHvrAl8OHVWDPKgmaE4gUsctboyFYUx</h1>

and keyword arguments for named groups:

>>> import unmatcher
>>> print unmatcher.reverse('(?P<foo>\w+)__(?P=foo)', foo='bar')
bar__bar

Note that a predefined value is not validated against actual subexpression for the capture group.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].