regex-do-3.0.1: PCRE wrapper

Safe HaskellSafe
LanguageHaskell2010

Text.Regex.Do.Type.Do

Synopsis

Documentation

newtype GroupReplacer b Source #

see Text.Regex.Do.Replace.Open defaultReplacer for example implementation

Constructors

GroupReplacer (MatchArray -> ReplaceAcc b -> ReplaceAcc b) 

Instances

(RegexLike Regex b, Regex b) => Replace All b (GroupReplacer b) b (E b) Source #

b: String | ByteString

Methods

replace :: All b -> GroupReplacer b -> b -> E b Source #

(RegexLike Regex b, Regex b) => Replace Once b (GroupReplacer b) b (E b) Source #

b: String | ByteString

Methods

replace :: Once b -> GroupReplacer b -> b -> E b Source #

Replace All ByteString (GroupReplacer ByteString) ByteString (E ByteString) Source #
replacer::GroupReplacer ByteString
replacer = defaultReplacer 1 tweak1
      where tweak1 bs1 = toByteString' $
                        if bs1 == toByteString "左" then
                              "ー右ー"
                               else "?"


    runFn1 `shouldBe` toByteString "100メートルー右ー折後、左"
        where runFn1 = let rx1 = toByteString "(?<=ル)(左)"
                           body1 = toByteString "100メートル左折後、左"
                       in replace (All rx1) replacer body1    
Replace Once ByteString (GroupReplacer ByteString) ByteString (E ByteString) Source # 
Replace [] (GroupReplacer b) b Source # 

Methods

replace :: (Extract' b, ToArray arr) => [arr] -> GroupReplacer b -> b -> b Source #

Replace Maybe (GroupReplacer b) b Source # 

Methods

replace :: (Extract' b, ToArray arr) => Maybe arr -> GroupReplacer b -> b -> b Source #

data ReplaceAcc b Source #

Constructors

ReplaceAcc 

Fields

  • acc :: b

    content with some replacements made

  • pos_adj :: Int

    position adjustment: group replacement length may differ from replaced text length

Instances

Functor ReplaceAcc Source # 

Methods

fmap :: (a -> b) -> ReplaceAcc a -> ReplaceAcc b #

(<$) :: a -> ReplaceAcc b -> ReplaceAcc a #

data Body b Source #

Haystack

Constructors

Body b 

Instances

Functor Body Source # 

Methods

fmap :: (a -> b) -> Body a -> Body b #

(<$) :: a -> Body b -> Body a #

Applicative Body Source # 

Methods

pure :: a -> Body a #

(<*>) :: Body (a -> b) -> Body a -> Body b #

(*>) :: Body a -> Body b -> Body b #

(<*) :: Body a -> Body b -> Body a #

type PosLen = (MatchOffset, MatchLength) Source #

Offset, Length

type E a = Either String a Source #

Left String returns regex construction error