From: Rob Biedenharn Date: 2008-12-04T05:20:57+09:00 Subject: Re: string with \ On Dec 3, 2008, at 12:49 PM, Vrone Ve wrote: > What if There is some optional value which may appear in strings > oftenly, and i want to check against its attribute value. or in other > words its not necesary to have Name with its value every time in the > string, and i want to have some checks on it ( e.g if Name attribute > is > there then grab its value before the back slash, then moving along all > other attributes and chk there occurance take their value) > > thanks again irb> "ABC\\Name X\\Gender Z\\Person ".scan(/([^\\]+)\\(\w+)\s?/) => [["ABC", "Name"], ["X", "Gender"], ["Z", "Person"]] irb> alist = _ => [["ABC", "Name"], ["X", "Gender"], ["Z", "Person"]] irb> alist.rassoc('Name') => ["ABC", "Name"] irb> alist.rassoc('Person') => ["Z", "Person"] irb> alist.rassoc('Optional') => nil If you still can't figure it out, either hire someone or at least post your actual problem with some real data. Even a little code fragment that you think is close, but perhaps misbehaving in a few cases. Showing those cases as tests would be even better. ;-) -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com