Mega Code Archive

 
Categories / Ruby / String
 

Anchors anchor a pattern to the beginning (^) or end ($) of a line

opening = "This is a test. \nThis is a test. \n" puts opening.grep(/^this is/) puts opening.grep(/this is,$/)