Skip to main content

hlre

Interactively highlight regular expression matches.

What?

A TUI application that shows the matches of a (python-flavored) regular expression as you type it.

Why?

I really like using RegExr, but it uses the javascript regex engine and there are some subtle differences between the results there and what you get with python.

Installation

python3 -m pip install hlre

Usage

TLDR

  1. Run

    hlre -f nginx.log
    
  2. Type a regex and see the matches highlighted in nginx.log.

  3. Press Control-C to exit.

Input Sources

You can either highlight matches with the built-in example text, a string passed on the command line, or in an external file.

  • Built-in Demo Text

    hlre --demo-text
    
  • String

    hlre --text 'This is the regular expression subject.'
    
  • External File

    hlre --file nginx.log
    

    Reading in the whole file can slow this tool down quite a bit, so you probably want to do something like:

    hlre --file <(head -n 10 nginx.log)
    

    To look at just the first 10 lines.

Highlighting All Matches

By default, each line is treated as a seperate subject to match the regex on.

To highlight all matches in the subject, use the -a flag:

hlre --demo-text -a
# OR
hlre --file nginx.log --all

This uses re.finditer and the re.MULTILINE flag under the hood.

Customizing Highlight Styles

hlre uses prompt toolkit's HTML functionality, so any tag name that works there should work here. This tool does not currently support any custom attributes on tags (e.g style="...").

Here are some examples:

  • Underline the entire match, highlight capture groups in a dark red

    hlre --demo-text --highlight-style u --group-highlight-style firebrick
    
  • Highlight the entire match in green, bold the capture groups

    hlre --demo-text -s green -g b
    
  • Italicize the entire match, highlight capture groups in cyan

    hlre --demo-text -s i -g cyan
    

Metadata

Release files for hlre 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hlre 0.1.0
File Size Uploaded Provenance
hlre-0.1.0.macosx-10.7-x86_64.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hlre 0.1.0
File Interpreter ABI Platform
hlre-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / hlre-0.1.0.macosx-10.7-x86_64.tar.gz

Download URL hlre-0.1.0.macosx-10.7-x86_64.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6a90b701902ffc8f30ed13e44483fe1a8d7c9ce170c7f0a07f0d7d29ff6cafc0
BLAKE2b-256 checksum
How to use checksums
b122e7425b3ac6f82476de191d8aa37e134c916ba0689a23c28de9c986a09f60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release files / hlre-0.1.0-py3-none-any.whl

Download URL hlre-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b9817e19c0206f5b3e22ad234a2b80f7306fc69d0c2cd14bff34942229e6ca2
BLAKE2b-256 checksum
How to use checksums
60f6fcf3869e87991a39332a4e8a1403481e211c096c1c322e2e753994e09bbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Security for hlre 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page