Skip to content

Instantly share code, notes, and snippets.

@loadedsith
Created July 19, 2013 02:21
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 loadedsith/6034624 to your computer and use it in GitHub Desktop.
Save loadedsith/6034624 to your computer and use it in GitHub Desktop.
# Scan it for all instances of (unescaped) <rules>
# Each match will be an array containing the portion of string before
# the <rule>; and the <rule> itself (which may be empty on the last match)
choice.scan(Regexp.new("/(.*?(?<!\\)(?:\\\\)*)(<.*?>|$)/",nil,"u")) do |match|
local_res << match[0]
unless match[1].empty?
local_res << invoke(match[1].match(/<(.*?)>/)[1].to_sym)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment