https://github.com/dylex/anagrep
Test for anagrams with regular expressions
https://github.com/dylex/anagrep
anagram grep permutation regex
Last synced: 10 months ago
JSON representation
Test for anagrams with regular expressions
- Host: GitHub
- URL: https://github.com/dylex/anagrep
- Owner: dylex
- Created: 2020-11-30T01:37:58.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-11T16:10:52.000Z (about 5 years ago)
- Last Synced: 2025-01-23T19:14:39.984Z (12 months ago)
- Topics: anagram, grep, permutation, regex
- Language: Haskell
- Homepage: http://hackage.haskell.org/package/anagrep
- Size: 67.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
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