Mega Code Archive

 
Categories / Ruby / String
 

Adding another argument, a Fixnum, returns that portion of the matched data, starting at 0 in this instance

line = "A horse! this is a horse!" puts line[/^A horse/, 0]