I have string ["10000", "10001"] (please do not ask why it is string, I am fixing errors after one dude...) and now I have got problem with spliting each number as separate item, so for example I would like to have array like: [10000, 10001], but I have big problem with writing proper RegExp. Now I am doing so:
items.gsub(/[^\d]/, '').scan(/./).each do |collection_id|
my code here
end
which works with 1 digit ids, but not multi :-(. Could you help me please?
2.1.0 :001 > string = '["10000", "10001"]' => "[\"10000\", \"10001\"]" 2.1.0 :002 > require 'yaml' => true 2.1.0 :003 > YAML.load(string).map(&:to_i) => [10000, 10001] 2.1.0 :004 >JSON.parse(string).map(&:to_i)