Skip to content

Instantly share code, notes, and snippets.

@suzuki-kei
Created November 3, 2019 09:16
Show Gist options
  • Save suzuki-kei/eb5c1e53d5cef3ba6c6845fb4ecabcf4 to your computer and use it in GitHub Desktop.
Save suzuki-kei/eb5c1e53d5cef3ba6c6845fb4ecabcf4 to your computer and use it in GitHub Desktop.
#!/bin/ruby
#
# Amazon の URL から冗長な要素を削除する.
#
# Example:
# cat amazon-urls.txt | ruby reduce-amazon-url.rb
#
while line = gets do
url = line.chomp
if url =~ /\/dp\/([a-zA-Z0-9]+)/
puts "https://www.amazon.co.jp/dp/#{$1}"
else
puts url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment