This is Ruby 1.8.7 but should be same as for 1.9.x
I am trying to split a string for example:
a = \"foo.bar.size.split(\'.\').last\"
a = "foo.bar.size.split('.').last" p a.split(/(? ["foo", "bar", "size", "split('.')", "last"]
You are looking for Lookahead and Lookbehind assertions. http://www.regular-expressions.info/lookaround.html