开发者

Ruby regex: extract text between quotes

开发者 https://www.devze.com 2023-02-06 13:47 出处:网络
What is the best way to get quoted words 开发者_开发技巧/ phrases out of the text? This my attempt does not work properly:

What is the best way to get quoted words 开发者_开发技巧/ phrases out of the text?

This my attempt does not work properly:

text.scan(/\"([^"]+)/)


I think you want:

text.scan(/"([^"]*)"/)

It works in Rubular.

0

精彩评论

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