Skip to content

Instantly share code, notes, and snippets.

@peterhil
Created September 13, 2015 14:08
Show Gist options
  • Save peterhil/c7a9547dafec4c425494 to your computer and use it in GitHub Desktop.
Save peterhil/c7a9547dafec4c425494 to your computer and use it in GitHub Desktop.
Clean up a Facebook chat from https://www.facebook.com/messages/
#!/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