Skip to content

Instantly share code, notes, and snippets.

@coderek
Created August 14, 2014 18:54
Show Gist options
  • Save coderek/3093b65b00d3182788cb to your computer and use it in GitHub Desktop.
Save coderek/3093b65b00d3182788cb to your computer and use it in GitHub Desktop.
_, seq = STDIN.read.scan(/(\n>THREE[^\n]*\n)([^>]*)\n/).flatten
p _, seq
# you can run this file as `ruby scan.rb < test`, where test contains the text to match
# it matches something like this, note the new line at beginning
#
# >THREE zengqiang
# xiaoni
#
# output
# "\n>THREE zengqiang\n"
# "xiaoni"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment