简体   繁体   English

如何在Ruby中迭代所有regexp匹配的字符串?

[英]How to iterate through string for all regexp matches in Ruby?

We have a string: " <b><c><d><e> " 我们有一个字符串:“ <b><c><d><e>

And this Regexp: /<(\\w+)>/i 而这个Regexp: /<(\\w+)>/i

How can I get ALL of the matches from current string? 如何从当前字符串中获取所有匹配项?

"<b><c><d><e>".scan(/<(\w+)>/)

请参阅ruby-docs上的扫描

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM