开发者

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

开发者 https://www.devze.com 2023-01-24 00:16 出处:网络
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.Th

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

精彩评论

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