Ruby regex or string manipulation -
Ruby regex or string manipulation -
i trying create rails app takes in rss feeds , displays news stories page.
when summary article save string, summary every single story has lot of markup @ end unnecessary. example:
the miami dolphins have suspended defensive lineman after allegedly touched women , took "aggressive fighting stance" when police force attempted arrest him, according probable cause affidavit.<div class="feedflare"> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:yil2auoc8za"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=yil2auoc8za" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:7q72wntakba"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=7q72wntakba" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:v_sglipbpwu"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=4w6duenqkry:kemjff3bscg:v_sglipbpwu" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:qj6idk7rits"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=qj6idk7rits" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:gin9vfwoqvq"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=4w6duenqkry:kemjff3bscg:gin9vfwoqvq" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/rss/cnn_topstories/~4/4w6duenqkry" height="1" width="1"/>
the line want maintain in is:
the miami dolphins have suspended defensive lineman after allegedly touched women , took "aggressive fighting stance" when police force attempted arrest him, according probable cause affidavit.
i want parse out including , after <div class="feedflare">
tag.
i stumped on how this. if please provide ruby string manipulation method or regular look method can utilize this, appreciate it. have been stumped on quite while, since i'm novice ruby , regex.
i take more close , realize simple er look enough. take too.
a=%q[the miami dolphins have suspended defensive lineman after allegedly touched women , took "aggressive fighting stance" when police force attempted arrest him, according probable cause affidavit.<div class="feedflare"> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:yil2auoc8za"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=yil2auoc8za" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:7q72wntakba"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=7q72wntakba" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:v_sglipbpwu"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=4w6duenqkry:kemjff3bscg:v_sglipbpwu" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:qj6idk7rits"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?d=qj6idk7rits" border="0"></img></a> <a href="http://rss.cnn.com/~ff/rss/cnn_topstories?a=4w6duenqkry:kemjff3bscg:gin9vfwoqvq"><img src="http://feeds.feedburner.com/~ff/rss/cnn_topstories?i=4w6duenqkry:kemjff3bscg:gin9vfwoqvq" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/rss/cnn_topstories/~4/4w6duenqkry" height="1" width="1"/>] a.gsub(/\<[^\>]+\>/m, "")
ruby-on-rails ruby regex string
Comments
Post a Comment