0

我有一个包含名称的文本,每个名称都写在两个撇号之间。例如:

'James' is the best player we had since 'Jane' left

我需要从文本中提取所有这些名称并将它们插入到我的数据库中的一列中。我是 Rails 的新手,我想知道如何最好地解析这段文本。

4

1 回答 1

2
"'James' is the best player we had since 'Jane' left".scan(/\'(\w+)\'/).flatten 
#=> ["James", "Jane"]
于 2012-04-28T21:31:23.857 回答