Haskell: use Data.Text.replace to replace only the first occurrence of a text value -
how replace first occurrence of "substring" (actually data.text.text) in text value in haskell in efficient way?
you can breakon
substring,
breakon :: text -> text -> (text, text)
to split text
2 parts @ first occurrence of pattern, replace substring @ start of sec component:
replaceone :: text -> text -> text -> text replaceone pattern substitution text | t.null = text -- pattern doesn't occur | otherwise = t.concat [front, substitution, t.drop (t.length pattern) back] (front, back) = breakon pattern text
haskell
No comments:
Post a Comment