anagrep-0.1.0.0: Find strings with permutations (anagrams) that match a regular expression
Safe HaskellNone
LanguageHaskell2010

Text.Regex.Anagram

Description

The basic use of this module is to first parse a regular expression string (like "[mn]{2,5}[eio]+s?") into an Anagrex with makeAnagrex. This can then be used to efficiently test candidate strings with testAnagrex.

Synopsis

Documentation

data Anagrex Source #

A compiled regular expression pattern to match anagrams. Represented as an (expanded) list of alternative AnaPats.

Instances

Instances details
Show Anagrex Source # 
Instance details

Defined in Text.Regex.Anagram.Compile

IsString Anagrex Source # 
Instance details

Defined in Text.Regex.Anagram.Compile

Methods

fromString :: String -> Anagrex #

FoldCase Anagrex Source #

Used to create a case-insensitive version of a pattern. Note that this involves a re-compilation of the parsed AnaPattern. You can avoid this by using makeAnagrexCI.

Instance details

Defined in Text.Regex.Anagram.Compile

NFData Anagrex Source # 
Instance details

Defined in Text.Regex.Anagram.Compile

Methods

rnf :: Anagrex -> () #

makeAnagrex :: String -> Either String Anagrex Source #

Build a regular expression for matching anagrams from a string, returning Left error for invalid or unsupported regular expressions. (Uses parseRegex.) This works by first expanding out a list of alternative patterns (like "a|(b(c|d))" into ["a","bc","bd"]) and then creating optimized pattern represenations for each.

makeAnagrexCI :: String -> Either String (CI Anagrex) Source #

Build a case-insensitive version of a pattern. This is more efficient than mk since it avoids the complication of the case-sensitive version as well. Uses unsafeMk so the original version is also case-folded.

testAnagrex :: Anagrex -> String -> Bool Source #

Check if any permutations of a string matches a parsed regular expression. Always matches the full string.

testAnagrexCI :: CI Anagrex -> CI String -> Bool Source #

Test a case-insensitive pattern against a case-insensitive string. You can also directly use foldCase on both the pattern and the string to test.