ruby - What are $3 $2 in coderay/redcloth/textile/markdown? -
ruby - What are $3 $2 in coderay/redcloth/textile/markdown? -
can explain $3 , $2 syntax when using coderay?
http://railscasts.com/episodes/207-syntax-highlighting?view=comments
require 'coderay' def coderay(text) text.gsub(/\<code( lang="(.+?)")?\>(.+?)\<\/code\>/m) content_tag("notextile", coderay.scan($3, $2).div(:css => :class)) end end i've seen $4. these defined, , reference, , there documentation it?
i don't know proper question inquire these. basically... they? must understand.
they created gsub, , called "captures". have contents of matched parentheses in regular expression. in example, $1 matches lang="(.+?)", $2 match .+? within lang attribute, , $3 match other .+?, tag contents. more precisely, $1 special global variable identical regexp.last_match[1], is, in turn, same regexp.last_match.captures[0]. others.
you can find regexp-related special global variables reference in regexp documentation.
it has nil coderay/redcloth, , regular expressions , core ruby.
ruby
Comments
Post a Comment