From: Vrone Ve Date: 2008-12-04T00:52:30+09:00 Subject: Re: string with \ Rob Biedenharn wrote: > On Dec 3, 2008, at 10:12 AM, Vrone Ve wrote: > >> cheers > irb> string = "abc/ def/ ghi/" > => "abc/ def/ ghi/" > irb> string.split(%r{/\s*}) > => ["abc", "def", "ghi"] > > You could use parallel assignment, but I'd question whether you really > wanted three variables rather than a three-element array. > > a, d, g = string.split(%r{/\s*}) > > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob@AgileConsultingLLC.com thanks Rob, My detailed question is regarding a string something like String "ABC\Name X\Gender " and I want to scan the string for each of the element(i.e. Name, Gender) and whereever Name is written in the string, I want to grab the value placed before the back slash and store it in a variable. same is the case with gender and/or with any other attribute i want to be in this string. Cheers -- Posted via http://www.ruby-forum.com/.