Skip to main content

Linter for (Pygments) regular expressions

Project description

Regexlint is intended to be run as a linter against an importable Pygments lexer, and flag problems that will prevent the lexer from performing well (since we don’t have branch coverage for lexers :)

As a simple example, alternations are first match, so it will flag this as never matching “elseif”:


It also understands some Pygments internals, for example bygroups(...)` needs to have the same number of args as the regex has capture groups. Too many will result in duplicate text; too few will result in missing text. There should also not be any gaps between the capture groups, so this example flags two problems:

(r'(foo)\s+(bar)', bygroups(Blah)),


make demo
regexlint pygments.lexers.web:HtmlLexer
python3 regexlint/ pygments.lexers.web


  • Figure out which phase should remove unnecessary backslashes

  • Write the alternation expander, so that ([ax]|a[bc]) fails the alternation order checks

  • Make more general than just for Pygments


This project is licensed under the Apache Public License, see COPYING

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

regexlint-2.0.tar.gz (33.5 kB view hashes)

Uploaded Source

Built Distribution

regexlint-2.0-py3-none-any.whl (30.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page