Skip to content

Instantly share code, notes, and snippets.

@analyticsPierce
Last active December 24, 2015 22:19
Show Gist options
  • Save analyticsPierce/6871644 to your computer and use it in GitHub Desktop.
Save analyticsPierce/6871644 to your computer and use it in GitHub Desktop.
Here is a helpful script for loading a csv file into an array so you can test regex.
#! /usr/bin/env ruby
require 'csv'
# step 1: import sproducts into an array
@file = "<your path and file>"
@sproducts = []
CSV.foreach(@file, :headers => false) do |row|
@sproducts << row[0]
end
# create variable with regex function I want to test and print the matches
@sproducts.each { |line|
@matches = /^A.*/.match(line)
if @matches.nil?
else
puts @matches.to_s
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment