Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2012 00:07
Show Gist options
  • Save anonymous/4281311 to your computer and use it in GitHub Desktop.
Save anonymous/4281311 to your computer and use it in GitHub Desktop.
def get_quotes(block_of_text)
lines = block_of_text.split(/\n+/)
lines.map do |line|
m = line.match(/^(.+?):\s(.+)$/) # match the line
next unless m # skip any lines that don't look like "some name: some text"
[ m[1], m[2] ]
end.compact
end
text = <<-TEXT
Robert, Earl of Grantham: Really, even with a servant?!
Cora, Countess of Grantham: Oh Robert, don't catch me out. I'm simply saying I fully see why you want to help him.
Robert, Earl of Grantham: But.
Cora, Countess of Grantham: But is this the right way - to employ him for a job he can't do? Is it any wonder the others' noses are put out.
Robert, Earl of Grantham: I just want to give him a chance.
Posted by scifiscully at 20:07 No comments:
Email This
BlogThis!
Share to Twitter
Share to Facebook
Links to this post
Labels: cora countess of grantham, robert earl of grantham
I'm Going Down. Coming?
[S1, Ep1]
Lady Sybil: I'm going down. Coming?
Lady Mary: In a moment. You go.
Lady Sybil: I know you're sad about Patrick. Whatever you say, I know it.
TEXT
puts get_quotes(text).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment