2012/4/9 Iachetti Federico MartùÏ <iachetti.federico / gmail.com>: > Here's a possible approach > > If there should be just one match: > > pry(main)> var = "this sentence is my variable and the important information > is {inside these brackets}" > => "this sentence is my variable and the important information is {inside > these brackets}" > pry(main)> new_var = var.match(/({.*})/)[1] > => "{inside these brackets}" > > If there could be more than one match: > > pry(main)> new_var2 = var.match(/({.*})/).captures > => ["{inside these brackets}"] > pry(main)> > > new_var has only a match, while new_var2 has an array of all the > occurrencies Careful, the * is greedy, so it will consume as many characters as it can: > s = "adf {firs¥åt one} seomt¥åhing {seco¥ånd one} dfdsf¥å" => "adf {first one} seomthing {second one} dfdsf" > s[/({.*})/¥å] => "{first one} seomthing {second one}" That's why I used the negative character set, to match everything that is not a closed bracket. You can also use the ? modifier: > s[/({.*?})¥å/] => "{first one}" Jesus.