Forum: Ruby Pattern matching Question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Raju A. (Guest)
on 2008-12-04 19:53
Hi ,
I have a below log text
ADS=<GSP><ADS><AD n="1" slot="s" visible_url="www.w9.com"
url="http://xyz.com:80/srv/redirect/?key=vvMN3-AAA&amp;...
catid="all_tv" view_id="vPuC" provider="AdagioFeed"><LINE1>gt sv
ca</LINE1><LINE2>line 1 line 2</LINE2><LINE3 /></AD><AD n="2" slot="s"
visible_url="www.rice.edu"
url="http://xyz:80/srv/redirect/?key=kN3-AAB&amp;s="
catid="cat_homeservices_install_tv" view_id="kR-AAB"
provider="AdagioFeed"><LINE1>c2 tv installation</LINE1><LINE2>line
1</LINE2><LINE3 /></AD><AD n="1" slot="a" visible_url="samsung.com/us"
url="http://xyz.com:80/srv/redirect/?info=ACoJO&amp;awt...
provider="GoogleFeed"><LINE1>&lt;b&gt;Samsung&lt;/b&gt; New
&lt;b&gt;SAMSUNG&lt;/b&gt; TV</LINE1><LINE2>Stylish
&lt;b&gt;LCD&lt;/b&gt; Full &lt;b&gt;HDTV&lt;/b&gt; with Quality. Find
Karim&amp;#39;s Design with &lt;b&gt;Samsung&lt;/b&gt; TV</LINE2><LINE3
/></AD><AD n="2" slot="a" visible_url="www.AbesOfMaine.com"
url="www.xyz.com:80/srv/redirect/?info=AGqQ__&amp;awt=1&amp;s="
provider="GoogleFeed"><LINE1>&lt;b&gt;LN32A450 HDTV&lt;/b&gt; on
Sale</LINE1><LINE2>Great Deals on &lt;b&gt;Samsung
Ln32a450&lt;/b&gt;</LINE2><LINE3>In Stock, Free Shipping, Order
Now</LINE3></AD><AD n="3" slot="a" visible_url="www.smart-review.com"
url="http://xyz.com:80/srv/redirect/?info=ANmELI_&amp;a...
provider="GoogleFeed"><LINE1>Top Rated HDTVs for
2008</LINE1><LINE2>1080p High DefinitionTelevisions
-</LINE2><LINE3>Owner Reviews. 2008 Buying
Guide.</LINE3></AD></ADS><VIEW_BASE_URL>a9adam-staging-adserver.amazon.com:80/srv/view</VIEW_BASE_URL><CATEGORIES>

I want to extract data in the below format. Could someone give me the
pattern for this ? Thanks a lot in Advance.

n="1" slot="s" visible_url="www.w9.com" provider="AdagioFeed" <LINE1>gt
sv ca</LINE1>
n="2" slot="s" visible_url="www.rice.edu" provider="AdagioFeed"
<LINE1>c2 tv installation</LINE1>
n="1" slot="a" visible_url="samsung.com/us" provider="GoogleFeed"
<LINE1>&lt;b&gt;Samsung&lt;/b&gt; New &lt;b&gt;SAMSUNG&lt;/b&gt;
TV</LINE1>
n="2" slot="a" visible_url="www.AbesOfMaine.com" provider="GoogleFeed">
<LINE1>&lt;b&gt;LN32A450 HDTV&lt;/b&gt; on Sale</LINE1>
n="3" slot="a" visible_url="www.smart-review.com" provider="GoogleFeed">
<LINE1>Top Rated HDTVs for 2008</LINE1>

One more thing is some lines are like &lt;b&gt;Samsung&lt;/b&gt; New
&lt;b&gt;SAMSUNG&lt;/b&gt; Will there be a way to eextract only "Samsung
New SAMSUNG" out of this ?
Rüdiger Brahns (Guest)
on 2008-12-08 12:15
(Received via mailing list)
Hi Raju

If you don't have a solution yet, please post the original log text to
pastebin.com or something like that, so that I can see where line breaks
are.

R.
Raju A. (Guest)
on 2008-12-08 18:43
Rüdiger Brahns wrote:
> Hi Raju
>
> If you don't have a solution yet, please post the original log text to
> pastebin.com or something like that, so that I can see where line breaks
> are.
>
> R.

Hi Rüdiger
I got a solution for this. Thank you.

-Raju
This topic is locked and can not be replied to.