Regexp pre_match

9 views
Skip to first unread message

John Merlino

unread,
Sep 6, 2012, 1:40:00 AM9/6/12
to Ruby on Rails: Talk
I looked in ruby documentation

http://www.ruby-doc.org/core-1.9.3/Regexp.html

I cannot find a method called pre_match but its used in Rails...

@template.instance_variable_get("@#{Regexp.last_match.pre_match}")

Rick

unread,
Sep 6, 2012, 10:21:21 AM9/6/12
to rubyonra...@googlegroups.com

John Merlino

unread,
Sep 6, 2012, 11:41:34 AM9/6/12
to Ruby on Rails: Talk
yep, last_match returns a MatchData object, which contains some
wrapper methods, including a string of the last successful pattern
match. Hence, pre_match would fall under MatchData, not Regexp.
Reply all
Reply to author
Forward
0 new messages