# Extract alphanumeric text from a string

**URL:** <https://www.ruby-forum.com/t/extract-alphanumeric-text-from-a-string/172604>\
**Category:** Ruby\
**Created:** [July 24, 2009, 12:06am UTC](https://www.ruby-forum.com/t/extract-alphanumeric-text-from-a-string/172604 "2009-07-24T00:06:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abir84](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3da27b/32.png) [@abir84](https://www.ruby-forum.com/u/abir84)\
**Post date:** [July 24, 2009, 12:06am UTC](https://www.ruby-forum.com/t/extract-alphanumeric-text-from-a-string/172604/1 "2009-07-24T00:06:09Z")

</div>

Hello  
I have a string extracted from a news flow wich contains heteregenous  
parts. I need to extract the part wich represents a natural text (the  
content of the summary). I don’t know how to do this, but I guess I must  
apply a regular expression??

this two exemples of the flow :

“summary”:{“direction”:“ltr”,“content”:“Voters’ hopes for the Iraqi  
Kurdistan  
elections”},“likingUsers”:[],“comments”:[],“annotations”:[],“origin”:{“streamId”:“feed/[http://newsrss.bbc.co.uk/rss/newsonline\_world\_edition/front\_page/rss.xml",“title”:"BBC](http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml%22,%22title%22:%22BBC)  
News | News Front Page | World  
Edition”,“htmlUrl”:“[Home - BBC News](http://news.bbc.co.uk/go/rss/-/2/hi/default.stm)”}}

=\> Here I want to extract “Voters’ hopes for the Iraqi Kurdistan  
elections”

“summary”:{“direction”:“ltr”,“content”:“Microsoft’s disappointing fiscal  
fourth-quarter results reflect a sharp slowdown in software sales as  
demand for new personal computers wanes in the recession.

\<iframe  
src="[http://feedads.g.doubleclick.net/~ah/f/i8hpomaon0k21n7jujntil2004/468/60#http%3A%2F%2Fwww.marketwatch.com%2Fenf%2Frss.asp%3Fguid%3D%257B377DE823-5268-4DA1-9194-FDB657AA15DC%257D%26siteid%3Drss%26rss%3D1\](http://feedads.g.doubleclick.net/~ah/f/i8hpomaon0k21n7jujntil2004/468/60#http%3A%2F%2Fwww.marketwatch.com%2Fenf%2Frss.asp%3Fguid%3D%257B377DE823-5268-4DA1-9194-FDB657AA15DC%257D%26siteid%3Drss%26rss%3D1%5C)”  
width="100%" height="60" frameborder="0" scrolling="no"  
marginwidth="0" marginheight="0"\>

\n\<a  
href="[http://feeds.marketwatch.com/~ff/marketwatch/topstories?a=\_AV98AmZ11c:fu-PHxqGjGM:yIl2AUoC8zA\](http://feeds.marketwatch.com/~ff/marketwatch/topstories?a=_AV98AmZ11c:fu-PHxqGjGM:yIl2AUoC8zA%5C)“\>\<img  
src="[http://feeds.feedburner.com/~ff/marketwatch/topstories?d=yIl2AUoC8zA\](http://feeds.feedburner.com/~ff/marketwatch/topstories?d=yIl2AUoC8zA%5C)”  
border="0"\>\<img  
src="[http://feeds.feedburner.com/~ff/marketwatch/topstories?d=qj6IDK7rITs\](http://feeds.feedburner.com/~ff/marketwatch/topstories?d=qj6IDK7rITs%5C)"

=\> here : "Microsoft’s disappointing fiscal fourth-quarter results  
reflect a sharp slowdown in software sales as demand for new personal  
computers wanes in the recession

sometimes the summary don’t contain any text … so I must return an  
empty string

Thanks
