All Projects → hoaproject → Regex

hoaproject / Regex

The Hoa\Regex library.

Projects that are alternatives of or similar to Regex

Npeg
PEGs for Nim, another take
Stars: ✭ 163 (-47.08%)
Mutual labels:  parser, regex, regular-expressions
Compiler
The Hoa\Compiler library.
Stars: ✭ 458 (+48.7%)
Mutual labels:  parser, hoa, library
unmatcher
Regular expressions reverser for Python
Stars: ✭ 26 (-91.56%)
Mutual labels:  regex, regular-expressions
lc-data-intro
Library Carpentry: Introduction to Working with Data (Regular Expressions)
Stars: ✭ 16 (-94.81%)
Mutual labels:  regex, regular-expressions
Pawn.Regex
🔎 Plugin that adds support for regular expressions in Pawn
Stars: ✭ 34 (-88.96%)
Mutual labels:  regex, regular-expressions
expressive-ts
A functional programming library designed to simplify building complex regular expressions
Stars: ✭ 78 (-74.68%)
Mutual labels:  regex, regular-expressions
tokenquery
TokenQuery (regular expressions over tokens)
Stars: ✭ 28 (-90.91%)
Mutual labels:  regex, regular-expressions
crystular
Crystal regex tester http://www.crystular.org/
Stars: ✭ 31 (-89.94%)
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 (-78.9%)
Mutual labels:  regex, regular-expressions
Visitor
The Hoa\Visitor library.
Stars: ✭ 269 (-12.66%)
Mutual labels:  hoa, library
Zformat
The Hoa\Zformat library.
Stars: ✭ 265 (-13.96%)
Mutual labels:  hoa, library
Re Flex
The regex-centric, fast lexical analyzer generator for C++ with full Unicode support. Faster than Flex. Accepts Flex specifications. Generates reusable source code that is easy to understand. Introduces indent/dedent anchors, lazy quantifiers, functions for lex/syntax error reporting, and more. Seamlessly integrates with Bison and other parsers.
Stars: ✭ 274 (-11.04%)
Mutual labels:  regex, regular-expressions
simplematch
Minimal, super readable string pattern matching for python.
Stars: ✭ 147 (-52.27%)
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 (-80.84%)
Mutual labels:  regex, regular-expressions
python-hyperscan
A CPython extension for the Hyperscan regular expression matching library.
Stars: ✭ 112 (-63.64%)
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 (-74.35%)
Mutual labels:  regex, regular-expressions
RgxGen
Regex: generate matching and non matching strings based on regex pattern.
Stars: ✭ 45 (-85.39%)
Mutual labels:  regex, regular-expressions
Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (-5.19%)
Mutual labels:  parser, library
Vmime
VMime Mail Library
Stars: ✭ 218 (-29.22%)
Mutual labels:  parser, library
moar
Deterministic Regular Expressions with Backreferences
Stars: ✭ 19 (-93.83%)
Mutual labels:  regex, regular-expressions

Hoa


Build status Code coverage Packagist License

Hoa is a modular, extensible and structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\Regex

Help on IRC Help on Gitter Documentation Board

This library provides tools to analyze regular expressions and generate strings based on regular expressions (Perl Compatible Regular Expressions).

Learn more.

Installation

With Composer, to include this library into your dependencies, you need to require hoa/regex:

$ composer require hoa/regex '~1.0'

For more installation procedures, please read the Source page.

Testing

Before running the test suites, the development dependencies must be installed:

$ composer install

Then, to run all the test suites:

$ vendor/bin/hoa test:run

For more information, please read the contributor guide.

Quick usage

As a quick overview, we propose to see two examples. First, analyze a regular expression, i.e. lex, parse and produce an AST. Second, generate strings based on a regular expression by visiting its AST with an isotropic random approach.

Analyze regular expressions

We need the Hoa\Compiler library to lex, parse and produce an AST of the following regular expression: ab(c|d){2,4}e?. Thus:

// 1. Read the grammar.
$grammar  = new Hoa\File\Read('hoa://Library/Regex/Grammar.pp');

// 2. Load the compiler.
$compiler = Hoa\Compiler\Llk\Llk::load($grammar);

// 3. Lex, parse and produce the AST.
$ast      = $compiler->parse('ab(c|d){2,4}e?');

// 4. Dump the result.
$dump     = new Hoa\Compiler\Visitor\Dump();
echo $dump->visit($ast);

/**
 * Will output:
 *     >  #expression
 *     >  >  #concatenation
 *     >  >  >  token(literal, a)
 *     >  >  >  token(literal, b)
 *     >  >  >  #quantification
 *     >  >  >  >  #alternation
 *     >  >  >  >  >  token(literal, c)
 *     >  >  >  >  >  token(literal, d)
 *     >  >  >  >  token(n_to_m, {2,4})
 *     >  >  >  #quantification
 *     >  >  >  >  token(literal, e)
 *     >  >  >  >  token(zero_or_one, ?)
 */

We read that the whole expression is composed of a single concatenation of two tokens: a and b, followed by a quantification, followed by another quantification. The first quantification is an alternation of (a choice betwen) two tokens: c and d, between 2 to 4 times. The second quantification is the e token that can appear zero or one time.

We can visit the tree with the help of the Hoa\Visitor library.

Generate strings based on regular expressions

To generate strings based on the AST of a regular expressions, we will use the Hoa\Regex\Visitor\Isotropic visitor:

$generator = new Hoa\Regex\Visitor\Isotropic(new Hoa\Math\Sampler\Random());
echo $generator->visit($ast);

/**
 * Could output:
 *     abdcde
 */

Strings are generated at random and match the given regular expression.

Documentation

The hack book of Hoa\Regex contains detailed information about how to use this library and how it works.

To generate the documentation locally, execute the following commands:

$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open

More documentation can be found on the project's website: hoa-project.net.

Getting help

There are mainly two ways to get help:

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know.

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE for details.

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].