haskell正则表达式替换 [英] haskell regex substitution
问题描述
Text.Regex code>,它虽然体面,却缺少我喜欢的一些东西。是否有任何基于pcre的软件包会进行替换,或者我坚持使用它?解决方案正则表达式API in regex -base是通配的字符容器。做一些通用的拼接来实现替换将非常困难。我不想提供一个蹩脚的泛型例程。
写一个小函数来完成你想要的替换只是一个更好的主意,它可以写成匹配你的容器。
Despite the ridiculously large number of regex matching engines for Haskell, the only one I can find that will substitute is Text.Regex
, which, while decent, is missing a few thing I like from pcre. Are there any pcre-based packages which will do substitution, or am I stuck with this?
解决方案 The regular expression API in regex-base is generic to the container of characters to match. Doing some kind of splicing generically to implements substitution would be very hard to make efficient. I did not want to provide a crappy generic routine.
Writing a small function to do the substitution exactly how you want is just a better idea, and it can be written to match your container.
这篇关于haskell正则表达式替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!