Skip to content

Instantly share code, notes, and snippets.

@tyeth
Forked from fghber/Regex Tools & Resources.md
Created September 28, 2019 19:06
Show Gist options
  • Save tyeth/4477050749409d063adadcf097d0c980 to your computer and use it in GitHub Desktop.
Save tyeth/4477050749409d063adadcf097d0c980 to your computer and use it in GitHub Desktop.

RegEx

Online Regex Tester Suites & Code Generators

  1. regex101 Online regex tester for PHP, PCRE, JavaScript and Python that highlights pattern and matches on the fly. Also features a Code generator and a regex debugger!
    https://regexr.com/ Online regex tester with gut regex replace and explain functionality.
    https://www.debuggex.com/ Can show neat expression diagrams (not active anymore).
    https://regexper.com/ translates regular expressions into an SVG image (for documentation or embedding)

Regex Expression Generator UI & Code Generator & Explanator

txt2re: regular expression generator (with code generator for perl php python java javascript coldfusion c c++ ruby vb vbscript j# c# c++.net vb.net)
Perl YAPE::Regex::Explain
Regex Generator++ Automatic Generation of Text Extraction Patterns from Examples
frak frak transforms collections of strings into regular expressions. Available as a command line utility (Clojure) and a JavaScript library.

Regex Pattern Libraries

http://regexlib.com/ Regular Expression Library. Currently has 7601 expressions from 2492 contributors (most are subpar IMHO).

Langauge-specifc Regex Tester

Here I list language/flavor specific online regex testers. The order of the listings is intentional. The most useful tools (in my view) for the specific flavor are listed first, then alternative and secondary testers follow.

.NET Regex Tester

Java Regex

https://www.freeformatter.com/java-regex-tester.html
http://java-regex-tester.appspot.com/
http://www.regexe.com/

JavaScript/ECMAScript

Node.js

http://www.rexv.org/

Perl

http://www.regexplanet.com/advanced/perl/index.html
http://www.rexv.org/

PHP

PHP Live Regex A Live Regular Expression Tester for PHP

R

https://spannbaueradam.shinyapps.io/r_regex_tester/
http://rextester.com/l/r_online_compiler

Ruby

http://rubular.com/
http://refiddle.com/

Google Analytics Regex Tester

http://www.analyticsmarket.com/freetools/regex-tester (and a general GA RE usage guide)

Utilities

Reverse Regex Random String Generators / Xeger

The principle is: Regex -> NFA, NFA -> minimal DFA, DFS-walk through the DFA (collecting all characters)

Python

sre_yield: a Python library, generate all values that can match a given regular expression, or count possible matches efficiently
rstr Random Strings in Python is a helper module to generating random strings of various types fuzzy testing, generating dummy data, etc.
Python Xeger: Python library to generate random strings from regular expressions.
sre_dump.py: sre_dump lets you dump the re tree back into a regular expression, useful for debugging.
inverse regex: given a regular expression string, produces random strings that match the expression.
EXREX: a command line tool and python module that generates all - or random - matching strings to a given regular expression and more.

Java

Java Xeger: Java library for generating strings that match a specific regular expression.
Rexlex

.NET

Fare - Finite Auutomata and Regular Epressions is an effort to bring a DFA/NFA (finite-state automata) implementation from Java to .NET. There are quite a few implementations available in other languages today. This project aims to fill the gap in .NET. and provides a port of the well established Java library dk.brics.automaton.
REX Rex is a simple command-line tool that takes a .NET regex or several regexes and generates strings that match all the regexes (download).

Ruby

regexp-examples Extends the Regexp class with the methods: examples (the generals *all strings that will match the given regular expression and random_example (one example).

Go

regen a tool to generate random strings from Go/RE2 regular expressions

Javascript

randexp.js Create random strings that match a given regular expression.

Perl

String::Random Perl module to generate random strings based on a pattern
YAPE::Regex Yet Another Parser/Extractor for Regular Expressions

Haskell

regex-genex Given a list of regexes, generate all possible strings that matches all of them.

C++

regxstring Random String Generator based on Regular Expression

Code beautifier & Syntax Highlither

Related Topics

htaccess tester

http://htaccess.mwl.be/
Mod Rewrite Generator can be used to turn dynamic URLs into search engine friendly static URLs (specific to transforming folders into parameters. Does not support more complex transformations, such as parameters to folders)

MS Office Wildcards

Finding and replacing characters using wildcards
OfficeToolTips: Using wildcards & Office Support

Alternatives

JavaScript Xeger more expressive regular expressions for JavaScript (i.e. sort of an alternative input language)

References

Comparison

https://www.regular-expressions.info/refadv.html

Character classes

https://www.regular-expressions.info/refcharclass.html

Perl

https://perldoc.perl.org/perlretut.html
http://php.net/manual/en/regexp.reference.recursive.php

Python

https://docs.python.org/2/howto/regex.html
https://docs.python.org/3/howto/regex.html

ICU

ICU's Regular Expression loosely based on JDK 1.4 java.util.regex with some extensions. Used in R's stringi/stringr.
Regular Expressions as used in R

Javascript

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

.NET/C#

https://docs.microsoft.com/en-us/dotnet/standard/base-types/the-regular-expression-object-model

R

re2

Regular expression syntax accepted by Google/RE2 (also lists some syntax accepted by PCRE, PERL, and VIM) as avialable in many Google products (Sheets, Docs, Analytics, etc.) text version

Lua Patterns

Alternatives:

  • lrexlib, a multi-flavor regex library
  • LPeg, a powerful text parsing library for Lua based on Parsing Expression Grammar. It offers functions to create and combine patterns in Lua code, and also a language somewhat like Lua patterns or regular expressions to create small parsers.

Linux Text Processing Toolbelt

awk

sed

Tutorials

https://regexone.com/
https://www.hackerrank.com/domains/regex
http://troubleshooters.com/codecorn/littperl/perlreg.htm

Quizzes

https://regexcrossword.com/
https://github.com/firasdib/Freenode-regex-quiz/blob/master/quiz.txt

Internals

How a Regex Engine Works Internally Regular Expressions: Implementations and running times

Performance recommendations and best practices

https://www.regular-expressions.info/catastrophic.html
https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices

Comparision

Comparison of regular expression engines: Libraries, Languages, Features
Regular expression speed comparison
Performance comparison of regular expression engines

Perl Regex One-Liners

http://www.catonmat.net/blog/perl-one-liners-explained-part-six/
http://www.rexegg.com/regex-perl-one-liners.html

State Machine Compile, Lexer, Parser Generator

  • Ragel: compiles executable finite state machines from regular languages.

Research

reggae: Automated Test Generation for Complex Regular Expressions
Rex: a tool that explores .NET regexes and generates members efficiently. Try Rex online
Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)
Overview of Learning Regular Languages: Get a regexp from a string
Aho–Corasick algorithm
Counting and Random Generation of Strings in Regular Languages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment