From: kotin 76 Date: 2011-07-27T21:54:43+09:00 Subject: Re: String manuplation example Hi Hans Mackowiak and Shah, Thanks for your quick reply. I am executed your code. its giving string /dev/sda4. its really use full for me. just i want to know onemore logic for 1. i dont know how many character will come after /dev like it may come /dev/sda4 , /dev/sda1256 or /dev/sdaERT7890. But my aim is to extract the that word from /dev to end of that word like "/dev/sda4" , "/dev/sda1256" , "/dev/sdaERT7890". for this what logic i need to add after /dev in below of your logics stv = st.gsub("/dev/?") string.match(/[\/\w]+/)[0]#=> "/dev/?" Random string like string = "/dev/sda4 45225016 3702464 39225208 9% /" string = "/dev/sda1256 45225016 3702464 39225208 9% /" string = "/dev/sdaERT7890 45225016 3702464 39225208 9% /" string = "/dev/sda4sdfsd 45225016 3702464 39225208 9% /" string = "/dev/sda4fsdfs 45225016 3702464 39225208 9% /" form above string i need to extract /dev/sda4 , /dev/sda1256, /dev/sdaERT7890 , /dev/sda4sdfsd and /dev/sda4fsdfs please suggest your logic Regards Kotin Chirag Shah wrote in post #1013329: > You have static value '/dev/sda4'? then you can do the following > You can do gsub > i.e st = "/dev/sda4 45225016 3702464 39225208 9% /" > stv = st.gsub("/dev/sda4") > your_value = stv.to_a[0] > > kotin 76 wrote in post #1013327: >> Hi, >> >> I am new to ruby. >> >> I tried to extract the word from /dev/sda4 from below string. I did not >> get exact logic for this. >> >> the string is below one( spaces are there between words) . >> >> string = "/dev/sda4 45225016 3702464 39225208 9% /" >> >> please any one let me know the logic to extract word from /dev to endof >> that word. it mean up to /dev/sda4. >> >> >> i would appreciate any answer. >> >> Regards >> Kotin -- Posted via http://www.ruby-forum.com/.