replacement / substition with Haskell regex libraries

前端 未结 6 463
无人共我
无人共我 2021-02-04 01:20

Is there a high-level API for doing search-and-replace with regexes in Haskell? In particular, I\'m looking at the Text.Regex.TDFA or Text.Regex.Posix

6条回答
  •  迷失自我
    2021-02-04 01:51

    How about the Text.Regex.subRegex in package regex-compat?

    Prelude> import Text.Regex (mkRegex, subRegex)
    
    Prelude> :t mkRegex
    mkRegex :: String -> Regex
    
    Prelude> :t subRegex
    subRegex :: Regex -> String -> String -> String
    
    Prelude> subRegex (mkRegex "foo") "foobar" "123"
    "123bar"
    

提交回复
热议问题