Skip to content

Instantly share code, notes, and snippets.

@oleander
Created September 1, 2015 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleander/7f9c8bf4c210f67e78a9 to your computer and use it in GitHub Desktop.
Save oleander/7f9c8bf4c210f67e78a9 to your computer and use it in GitHub Desktop.
a = "A\s*(?<A>.+?(?=\nB\s*))"
b = "[\n]+B\s*(?<B>.+?(?=\nC\s*))"
c = "[\n]+C\s*(?<C>.+?(?=\nD\s*))"
d = "[\n]+D(?<D>(?=[^?]+^E).+?(?=\nE\s+)|.+?(?=\n))"
e = "((?=[\n]+E\s+)[\n]+E\s+(?<E>(.+?))\n)?"
all = "#{a}#{b}#{c}#{d}#{e}"
nothing = "?<nothing>A\s+"
result = []
output.scan(/(?<nr>^\d{1,2})\.\s+(?<content>.+?(?=A\s+))((?=#{all})(#{all})|(#{nothing}))/m) do
result << $~
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment