У меня проблемы с этим регулярным выражением, оно, кажется, не захватывает заголовки (все после последнего '.') Я протестировал регулярное выражение в нескольких источниках, и все они, кажется, получают правильную группировку. Это что-то с функцией сканирования, что я делаю неправильно?
##### data.csv file #####
## Web_Sites.Shopping.Newegg,...
## Web_Sites.Shopping.Newegg_Secure,...
## Web_Sites.Shopping.O'Reilly_Books,...
## Web_Sites.Shopping.PackageTrackr,...
#####
## Grab the title from the list
regex = '([\w_-]+)$'
## Open the CSV File
data_file = CSV.open("data.csv", "r")
## Set the file we will append the data.
my_file = File.new("titles.csv", 'a')
## For each line in the data file, get the correct title
data_file.each do |data|
note = data[0]
title = note.scan(regex)
my_file.print "#{note} : #{title}"
end
Спасибо,
Lf4