开发者

In Ruby, is scan() the only function that can return multiple results of regular expression matching?

Just to know more methods that can accomplish the 开发者_如何转开发same thing.


split( regex ) returns an array, leaving out all matches. Sometimes it's easier to specify what you don't want to see.


There are only two methods in the standard library which match a regular expression multiple times: gsub (and gsub!, of course) and scan. gsub returns a single string, so, yes, scan is the only one the returns multiple results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜