Mega Code Archive

 
Categories / Ruby / String
 

Grouping uses parentheses to group a subexpression, like this one that contains an alternation

opening = "this is a test\nthis is a test,\n" puts opening.grep(/t(h|i)s/)