Created
September 13, 2015 14:08
-
-
Save peterhil/c7a9547dafec4c425494 to your computer and use it in GitHub Desktop.
Clean up a Facebook chat from https://www.facebook.com/messages/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
# | |
# Clean up a Facebook chat | |
# | |
# Usage: | |
# 1) copy a chat from https://www.facebook.com/messages/, paste into new file `chat.md`. | |
# 2) ruby fb_cleanup.rb chat.md | |
# | |
# Author: Peter Hillerström (peterhil) | |
# LICENSE: MIT | |
chat = File.open(ARGV[0], "r:UTF-8", &:read) | |
puts chat.gsub /^ | |
([[:alpha:]]+\s+[[:alpha:]]+)\s+ # Name | |
(\d{2}\/\d{2}\/\d{4}\s+)?(\d{2}:\d{2})\s+ # Date and time | |
([[:alpha:]]+\s+[[:alpha:]]+) # Name | |
/ux, "\n- \\3 \\1\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment