operates a bit like classic grep printing out the lines matched
Moduleregex-1.1.0.2Haskell2010
Text.RE.Tools.Grep
- 5 types
- 1 class
- 11 values
- Packageregex-1.1.0.2
- Exports17
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceGrep.lhs
The Grep toolkit matches REs against each line of a text.
See the Regex Tools tutorial at http://re-tutorial-tools.regex.uk
specifies whether to return the lines matched or missed
Constructors
LinegetLineNumber :: LineNothe LineNo for this line
getLineMatches :: Matches sall the Matches of the RE on this line
returns a Line for each line in the file, enumerating all of the matches for that line
returns a Line for each line in the argument text, enumerating all of the matches for that line
a GrepScript lists RE-action associations, with the first RE to match a line selecting the action to be executed on each line in the file
given a list of lines, apply the GrepScript to each line of the file
generate a grep report from a list of Line
given a velocity flag filter out either the lines matched or not
matched
IsRegex
4 declarationsthe IsRegex class allows polymorhic tools to be written that will work with a variety of regex back ends and text types
Methods
matchOnce :: re -> s -> Match sfinding the first match
matchMany :: re -> s -> Matches sfinding all matches
makeRegex :: (Functor m, Monad m, MonadFail m) => s -> m recompiling an RE, failing if the RE is not well formed
makeRegexWith :: (Functor m, Monad m, MonadFail m) => SimpleREOptions -> s -> m recomiling an RE, specifying the SimpleREOptions
makeSearchReplace :: (Functor m, Monad m, MonadFail m, IsRegex re s) => s -> s -> m (SearchReplace re s)compiling a SearchReplace template from the RE text and the template Text, failing if they are not well formed
makeSearchReplaceWith :: (Functor m, Monad m, MonadFail m, IsRegex re s) => SimpleREOptions -> s -> s -> m (SearchReplace re s)compiling a SearchReplace template specifying the SimpleREOptions for the RE
makeEscaped :: (Functor m, Monad m, MonadFail m) => (s -> s) -> s -> m reincorporate an escaped string into a compiled RE with the default options
makeEscapedWith :: (Functor m, Monad m, MonadFail m) => SimpleREOptions -> (s -> s) -> s -> m reincorporate an escaped string into a compiled RE with the specified SimpleREOptions
regexSource :: re -> sextract the text of the RE from the RE
Instances6IsRegex
IsRegex RE ByteStringDefined in regex-1.1.0.2 · Text.RE.TDFA.ByteString · orphanIsRegex RE ByteStringDefined in regex-1.1.0.2 · Text.RE.TDFA.ByteString.Lazy · orphanIsRegex RE StringDefined in regex-1.1.0.2 · Text.RE.TDFA.String · orphanIsRegex RE TextDefined in regex-1.1.0.2 · Text.RE.TDFA.Text · orphanIsRegex RE TextDefined in regex-1.1.0.2 · Text.RE.TDFA.Text.Lazy · orphanIsRegex RE (Seq Char)Defined in regex-1.1.0.2 · Text.RE.TDFA.Sequence · orphan
contains a compiled RE and replacement template
Constructors
SearchReplacegetSearch :: !rethe RE to match a string to replace
getTemplate :: !sthe replacement template with ${cap} used to identify a capture (by number or name if one was given) and
$$being used to escape a single $
Instances2Functor, Show
Functor (SearchReplace re)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.SearchReplace(Show re, Show s) => Show (SearchReplace re s)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.SearchReplace
search and replace all matches in the argument text; e.g., this function will convert every YYYY-MM-DD format date in its argument text into a DD/MM/YYYY date:
searchReplaceAll [ed|${y}([0-9]{4})-0*${m}([0-9]{2})-0*${d}([0-9]{2})///${d}/${m}/${y}|]search and replace the first occurrence only (if any) in the input text
e.g., to prefix the first string of four hex digits in the imput text,
if any, with 0x:
searchReplaceFirst [ed|[0-9A-Fa-f]{4}///0x$0|]LineNo
4 declarationsour line numbers are of the proper zero-based kind
Constructors
the first line in a file
extract a conventional 1-based line number
inject a conventional 1-based line number
Replace
0 declarationsmodule Text.RE.Replace