From: "Jesús Gabriel y Galán" Date: 2012-04-10T02:39:12+09:00 Subject: Re: How to pull out specific part of a variable and set to another variable? On Mon, Apr 9, 2012 at 7:28 PM, Charlie B. wrote: > I have a variable that is a long string.  The variable looks like this: > > "this sentence is my variable and the important information is {inside > these brackets}" > > The information I need is the information inside the brackets including > the brackets themselves, as the brackets are required for when I need to > reuse this information.  How do I pull out just that piece?  It will > ALWAYS be in brackets and be the only brackets in that variable. You can try the String#[] method and a regular expression to look for the brackets and what's inside. For example: s = "asdl­kmlsdmflkm­flk elfm lwemf­ le {asdf­sdf sdfds­f} asdf df " => "asdlkmlsdmflkmflk elfm lwemf le {asdfsdf sdfdsf} asdf df " > s[/{[^}]+}­/] => "{asdfsdf sdfdsf}" Jesus.