require 'pp' re = %r{ # Grammar rules go here (?: (?.+) ){0} # Invoke grammar here \g } m = re.match( 'text' ) puts m['thing'] # puts "text\n"