Skip to content

Instantly share code, notes, and snippets.

@foi
Created July 10, 2016 14:30
Show Gist options
  • Save foi/22836ecdebaa61a5effc8b1c25371299 to your computer and use it in GitHub Desktop.
Save foi/22836ecdebaa61a5effc8b1c25371299 to your computer and use it in GitHub Desktop.
# contents = File.read("2015.html")
contents = "---
layout: post
title: Astrofix. IC/Луна
date: '2015-09-06T22:05:13+00:00'
tags:
- astrofix
- ic
- 4 дом
- планета в доме
- Луна
- астрология
tumblr_url: http://it-karma.ru/post/128479569049
---
"
# raw_img_srcs_dq = contents.scan /src="(.*?)"/i
# raw_img_srcs_sq = contents.scan /src='(.*?)'/i
raw_tumblr_url_string = contents.scan(/(tumblr_url: ?(.+))/).first.first.split(",")
tumblr_url_string = raw_tumblr_url_string.first
tumblr_post_id = tumblr_url_string.split("tumblr_url: ").last.scan(/\d+/).first
puts tumblr_url_string
puts tumblr_post_id
new_contents = contents.sub tumblr_url_string, "#{tumblr_url_string}\ntumblr_post_id: #{tumblr_post_id}"
puts new_contents
# p raw_img_srcs_dq
# p raw_img_srcs_sq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment