anagrep: Find strings with permutations (anagrams) that match a regular expression

[ bsd3, library, program, text ] [ Propose Tags ] [ Report a vulnerability ]

Given a regular expression, determine if it matches any permutation of a given string. For example, "lt[aeiou]*" would match all strings with one 'l', one 't', and vowels (like "elate", "tail", "tl", etc.). Regular expression parsing is based on regex-tdfa and generally follows those semantics, but not all regular expression features are supported. For example, repeat modifiers cannot be applied to groups (such as "(abc)*"). The goal is for matching to be fairly efficient in most cases, given that this problem is NP-complete.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
ghc

Enable ghc-specific optimizations (on internal Natural representation)

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Dependencies anagrep, base (<5), bytestring, case-insensitive, containers, deepseq, ghc-prim, integer-gmp, regex-tdfa, vector [details]
License BSD-3-Clause
Copyright 2020, Dylan Simon
Author Dylan Simon
Maintainer dylan@dylex.net
Category Text
Source repo head: git clone git://github.com/dylex/anagrep
Uploaded by DylanSimon at 2025-05-07T16:25:43Z
Distributions NixOS:0.1.0.1
Executables anagrep
Downloads 340 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-05-07 [all 1 reports]

Readme for anagrep-0.1.0.1

[back to package description]
A Haskell library for matching permutations of regular expressions: http://hackage.haskell.org/package/anagrep And a command-line interface, useful for puzzle solving (e.g., which English word has one 'p', one 'q', and four vowels?): Usage: anagrep REGEXP [FILE]... Print lines in each FILE (or stdin) for which some permutation (anagram) matches the given REGEXP. REGEXP is a restricted regular expression that can contain the following patterns: Character matches x single literal character [aein-z] character set (any listed character) [^a-mou] negated character set (any character not listed) . any single character \x escape single literal character (no special meanings) Repeat modifiers - may only be applied to characters (above) {N,M} repeat character N-M times {N,} repeat character at least N times {N} equivalent to {N,N} ? equivalent to {0,1} * equivalent to {0,} + equivalent to {1,} Combination XY concatenation matches pattern X and Y in either order X|Y alternation matches pattern X or Y (X) grouping (only useful for alternation - note that successive grouped alternations involve a cross-product expansion and may be slow) Other regular expression features are not currently supported. Matching is always done on entire lines (like grep -x). Example: anagrep 'pq[aeiou]{4}' /usr/share/dict/words > opaque Flags: -b treat input as raw byte sequence (uses locale encoding by default) -i ignore case distinctions in patterns and data