From: Greg Willits Date: 2009-07-02T02:22:17+09:00 Subject: Re: converting the string Vlad Smith wrote: > Hi everybody! I`m sorry for asking a silly question .. i hope you`ll > find some time to assist > > while searching shrough html body i get the string : > src='https://sc.omniture.com/sc13_5/reports/chart.php?id=CPRIY_6NvJ_kj7s&s=www461.sj2&type=GIF' > width=624 height=280 border=0 align=absmiddle > usemap=#imIY_6NvJ_kj7s> > > how can i modify it to get just a plain link without tags and params? : > https://sc.omniture.com/sc13_5/reports/chart.php?id=CPRIY_6NvJ_kj7s&s=www461.sj2&type=GIF You'll have to expand this to take care of all possible scenarios, but here's an example: x = "" y = x.scan(/src=\"([\S\s]+?)\"/) That will return an array, and you'll have to fish the string out of the array with y[0][0]. That works specifically with proper HTML using double quotes where your examples above used malformed single quotes, but you can either use multple expressions, or build a more complex one to cover the various cases of quotes href, src, and other attributes names, etc. There's other ways to do it, this is just a small example to give you some ideas. -- gw -- Posted via http://www.ruby-forum.com/.