在Go中使用正则表达式分割字符串 [英] Split string using regular expression in Go

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

问题描述

我对Go非常陌生,并且一直享受它。我试图找到一种很好的方式来使用正则表达式而不是字符串来分割字符串。谢谢

http:/ /sf.github.com/go/strings.html?f:Split

解决方案

如果你只是想要分割某些字符,你可以使用 strings.FieldsFunc ,否则我会使用 regexp.FindAllString


I'm really new to Go, and have been enjoying it so far. I'm trying to find a good way to split a string using a regular expression instead of a string. Thanks

http://nsf.github.com/go/strings.html?f:Split!

解决方案

If you just want to split on certain characters, you can use strings.FieldsFunc, otherwise I'd go with regexp.FindAllString.

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

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