7stud -- wrote in post #991546: > However, note that > begin() and end() are the two elements of offset(), which we've already > discussed above. The idea was to additionally provide the relative > offsets within a match, not just the absolute offsets within the string. That's easy - subtract begin(0) which is the absolute offset of the start of the match. >> "foo bar" =~ /ba(.)/ => 4 >> $~.captures => ["r"] >> $~.begin(1) => 6 >> $~.begin(1) - $~.begin(0) => 2 -- Posted via http://www.ruby-forum.com/.