Skip to content

Instantly share code, notes, and snippets.

@chintanparikh
Created March 12, 2013 05:04
Show Gist options
  • Save chintanparikh/5140501 to your computer and use it in GitHub Desktop.
Save chintanparikh/5140501 to your computer and use it in GitHub Desktop.
lines = content.split("\n")
matches = []
non_matching_lines = lines.reject { |line| matches << line.scan(/[\n\r](.+):[\ \t]*(.+)/) }
matches.compact!
@epitron
Copy link

epitron commented Mar 12, 2013

Should be:

matches, non_matches = [], []

content.each_line do |line|
  match = line.scan(/[\n\r](.+):[\ \t]*(.+)/)
  p [:match, match]
  if match.any?
    matches << match
  else
    non_matches << line
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment