How do I split a string using a regex?

核能气质少年 提交于 2020-07-22 04:42:10

问题


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.)


回答1:


This may help you:

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

Real world haskell book has a nice chapter on it.



来源:https://stackoverflow.com/questions/20128557/how-do-i-split-a-string-using-a-regex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!