title: Retain only specified content in a string
body: <p>I have data in the following form in a file:</p>
  
  <pre><code> &lt;string1&gt;   abc:string2    &lt;http://yago-knowledge.org/resource/wikicategory_Sports_clubs_established&lt;/text\u003e\n______&lt;sha1\u003eqwjfowt5my8t6yuszdb88k2ehskjuh0&lt;/sha1\u003e\n____&lt;/revision\u003e\n__&lt;/page\u003e\n__&lt;page\u003e\n____&lt;title\u003ePortal:Tropical_cyclones/Anniversaries/August_22&lt;/title\u003e\n____&lt;ns\u003e100&lt;/ns\u003e\n____&lt;id\u003e7957689&lt;/id\u003e\n____&lt;revision\u003e\n______&lt;id\u003e446349886&lt;/id\u003e\n______&lt;timestamp\u003e2011-08-23T17:38:19Z&lt;/timestamp\u003e\n______&lt;contributor\u003e\n________&lt;username\u003eLightbot&lt;/username\u003e\n________&lt;id\u003e7178666&lt;/id\u003e\n______&lt;/contributor\u003e\n______&lt;comment\u003eDelink_non-obscure_units._Conversions._Report_bugs_to_[[User_talk:Lightmouse&gt;.
  </code></pre>
  
  <p>The delimiter in the above file is a tab (<code>\t</code>) i.e. <code>string1</code> is separated from <code>abc:string2</code>by <code>\t</code>. Similarly for the rest of the strings. </p>
  
  <p>Now I want to retain just alphabets, numbers, <code>/</code>, <code>:</code>,'.' and <code>_</code> within the strings which are enclosed within <code>&lt;&gt;</code>.  I want to delete all the characters apart from the specified ones from the strings which are enlosed in <code>&lt;&gt;</code>.</p>
  
  <p>Is there some way by which I may achieve this using linux commands or python? I want to replace all the unwanted characters by an underscore.</p>
  
  <pre><code> &lt;string1&gt;   abc:string2    &lt;http://yago-knowledge.org/resource/wikicategory_Sports_clubs_established_text_u003e_n_______sha1_u003eqwjfowt5my8t6yuszdb88k2ehskjuh0_sha1_u003e_n_____revision_u003e_n___/page_u003e_n___page_u003e_n_____title_u003ePortal:Tropical_cyclones/Anniversaries/August_22_/title_u003e_n_____ns_u003e100_/ns_u003e_n_____id_u003e7957689_/id_u003e_n_____revision_u003e_n_______id_u003e446349886_/id_u003e_n_______timestamp_u003e2011-08-23T17:38:19Z_/timestamp_u003e_n_______contributor_u003e_n_________username_u003eLightbot_/username_u003e_n_________id_u003e7178666_/id_u003e_n_______/contributor_u003e_n_______comment_u003eDelink_non-obscure_units._Conversions._Report_bugs_to___User_talk:Lightmouse&gt;.
  </code></pre>
  
  <p>Is there some way by which I may achieve this?</p>