slice(src, pattern, n = 0)
Class Public methods
EXPERIMENTAL
Parses src and return a string which was matched to
pattern. pattern should be described as Regexp.
require 'ripper'
p Ripper.slice('def m(a) nil end', 'ident') #=> "m"
p Ripper.slice('def m(a) nil end', '[ident lparen rparen]+') #=> "m(a)"
p Ripper.slice("<<EOS\nstring\nEOS",
'heredoc_beg nl $(tstring_content*) heredoc_end', 1)
#=> "string\n"