ITeye博客

Ruby 正则

samson7b · 2012-06-14 22:25 · Regex · 编程语言 · Markdown

(?=re) matches re at this point but does not consume it - you can look

forward for the context of a match without affecting $&.

 

str ="red, white, and blue"
p str.scan(/[a-z]+(?=,)/) 

 the result is :

=> ["red","white"]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。