regex-0.8.0.0: Toolkit for regex-base

Safe HaskellNone
LanguageHaskell2010

Text.RE.Tools.Sed

Contents

Synopsis

Documentation

sed :: IsRegex re ByteString => Edits IO re ByteString -> FilePath -> FilePath -> IO () Source #

read a file, apply an Edits script to each line it and write the file out again; "-" is used to indicate standard input standard output as appropriate

sed' :: (IsRegex re a, Monad m, Functor m) => Edits m re a -> a -> m a Source #

apply an Edits script to each line of the argument text

IsRegex

class Replace s => IsRegex re s where Source #

Minimal complete definition

matchOnce, matchMany, makeRegex, makeRegexWith, regexSource

Methods

matchOnce :: re -> s -> Match s Source #

matchMany :: re -> s -> Matches s Source #

makeRegex :: (Functor m, Monad m) => s -> m re Source #

makeRegexWith :: (Functor m, Monad m) => SimpleRegexOptions -> s -> m re Source #

regexSource :: re -> s Source #

Edit

data Edits m re s Source #

an Edits script will, for each line in the file, either perform the action selected by the first RE in the list, or perform all of the actions on line, arranged as a pipeline

Constructors

Select [(re, Edit m s)] 
Pipe [(re, Edit m s)] 

data Edit m s Source #

each Edit action specifies how the match should be processed

Constructors

Template s 
Function Context (LineNo -> Match s -> Location -> Capture s -> m (Maybe s)) 
LineEdit (LineNo -> Matches s -> m (LineEdit s)) 

data LineEdit s Source #

a LineEdit is the most general action thar can be performed on a line and is the only means of deleting a line

Constructors

NoEdit 
ReplaceWith s 
Delete 

Instances

Show s => Show (LineEdit s) Source # 

Methods

showsPrec :: Int -> LineEdit s -> ShowS #

show :: LineEdit s -> String #

showList :: [LineEdit s] -> ShowS #

applyEdits :: (IsRegex re s, Monad m, Functor m) => LineNo -> Edits m re s -> s -> m s Source #

apply an Edit script to a single line

applyEdit :: (IsRegex re s, Monad m, Functor m) => (s -> s) -> LineNo -> re -> Edit m s -> s -> m (Maybe s) Source #

apply a single edit action to a line, the function in the first argument being used to add a new line onto the end of the line where appropriate; the function returns Nothing if no edit is to be performed on the line, Just mempty to delete the line

applyLineEdit :: Monoid s => (s -> s) -> LineEdit s -> Maybe s Source #

apply a LineEdit to a line, using the function in the first argument to append a new line to the result; Nothing should be returned if no edit is to be performed, Just mempty to delete the line

LineNo

Text.RE

module Text.RE