`

Ruby 正则

 
阅读更多

(?=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"]
 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics