如何使用正则表达式分割字符串? [英] How do I split a string using a regex?

查看:96
本文介绍了如何使用正则表达式分割字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用正则表达式分割字符串.我已经浏览了Hackage上的各种正则表达式模块,但对它们却一无所知. (我注意到Data.List.Split,但它似乎也无法满足我的需求.)

I’d like to split a string using a regular expression. I have browsed the various regex modules on Hackage, but I can’t make any sense of them. (I have noticed Data.List.Split, but it doesn’t seem to offer what I need, either.)

推荐答案

这可能会帮助您:

ghci > import Text.Regex.Posix
ghci > getAllTextMatches ("good food" =~ ".ood" :: AllTextMatches [] String)
["good","food"]

现实世界中的haskell书具有很好的

Real world haskell book has a nice chapter on it.

这篇关于如何使用正则表达式分割字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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