title: transforming url's, python
body: <p>I have a txt file which contains some url's:</p>
  
  <pre><code>[http://igu.org.ru/ International Geographical Union - Russian National Committee]
  [http://www.geografos.org Colegio de Geógrafos - España]
  [http://www.geografs.org Col.legi de Geògrafs - Catalunya]
  [http://www.geografs.org]
  </code></pre>
  
  <p>now I want to transform this external links in the following way (in the fixed order):</p>
  
  <p>replace "<code>[url any text]</code>" with "<code>any text</code>", where "<code>url</code>" is an URL (e.g., starts with "http://").</p>
  
  <p>replace "<code>[url]</code>" with "<code>url</code>"</p>
  
  <pre><code>import re
  def openfile(filename):
      with codecs.open(filename, encoding="utf-8") as F:
          replace = F.read()
          replace = re.sub(r'\[http://.+ ...) # should replace "[url any text]" with "any text"
          replace = re.sub(...) # should replace "[url]" with "url"
  </code></pre>
  
  <p>any suggestions?</p>