haskell正则表达式替换 [英] haskell regex substitution

查看:135
本文介绍了haskell正则表达式替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管为Haskell引入了大量的regex em匹配引擎,但我能找到的唯一一个替代引擎是 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆