title: Python replace not replacing everything
body: <p>I'm trying to replace in my .html file all links with slash at the beginning to ../. For example:</p>
  
  <pre><code>&lt;link href="/wp-content/themes/newera/style.css?ver=1" id="stylesheet-css" media="all" rel="stylesheet" type="text/css"/&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>&lt;link href="../wp-content/themes/newera/style.css?ver=1" id="stylesheet-css" media="all" rel="stylesheet" type="text/css"/&gt;
  </code></pre>
  
  <p>So I've got this code:</p>
  
  <pre><code>with open(path, 'r') as file :
       filedata = str(file.read())
       filedata = filedata.replace('href="/', 'href="../')
       filedata = filedata.replace('src="/', 'src="../')
   with open(path, 'w') as file:
       file.write(filedata)
  </code></pre>
  
  <p>And It replaces but not everything. After running function in .html file is this (part of code):</p>
  
  <pre><code>&lt;link href="../feed/" rel="alternate" title="avium » Feed" type="application/rss+xml"/&gt;
    &lt;link href="../comments/feed/" rel="alternate" title="avium » Comments Feed" type="application/rss+xml"/&gt;
    &lt;link href="../about/feed/" rel="alternate" title="avium » About Comments Feed" type="application/rss+xml"/&gt;
    &lt;link href="../wp-content/uploads/2014/11/favicon.ico" rel="shortcut icon"/&gt;
    &lt;link href="../wp-content/plugins/fuse-social-floating-sidebar/inc/css/font-awesome.min.css" rel="stylesheet"/&gt;
    &lt;link href="/wp-content/themes/newera/style.css?ver=1" id="stylesheet-css" media="all" rel="stylesheet" type="text/css"/&gt;
    &lt;link href="/wp-content/themes/newera/framework/css/jquery.bxslider.css?ver=1" id="oi_bxslider_css-css" media="all" rel="stylesheet" type="text/css"/&gt;
    &lt;link href="/wp-content/themes/newera/framework/FlexSlider/flexslider.css?ver=1" id="flex-slider-css" media="all" rel="stylesheet" type="text/css"/&gt;
    &lt;link href="/wp-content/themes/newera/framework/css/prettyPhoto.css?ver=1" id="oi_prettyPhoto_css-css" media="all" rel="stylesheet" type="text/css"/&gt;
    &lt;link href="/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=4.0.1" id="contact-form-7-css" media="all" rel="stylesheet" type="text/css"/&gt;
    &lt;link href="/wp-content/plugins/revslider/rs-plugin/css/settings.css?rev=4.6.0&amp;ver=4.0.18" id="rs-plugin-settings-css" media="all" rel="stylesheet" type="text/css"/&gt;
  </code></pre>
  
  <p>Any ideas why it's not replacing everything?</p>
  
  <p>EDIT:</p>
  
  <p>ok here's full code: <a href="https://pastebin.com/n25f0CTh" rel="nofollow noreferrer">https://pastebin.com/n25f0CTh</a></p>
  
  <p>My full functions is:</p>
  
  <pre><code>with open(path, 'r') as file :
       filedata = str(file.read())
       filedata = filedata.replace('http://'+domain, '')
       filedata = filedata.replace('http://www.'+domain, '')
       filedata = filedata.replace('www.'+domain, '')
       filedata = filedata.replace(domain, '')
       filedata = filedata.replace('href="/', 'href="../')
       filedata = filedata.replace('src="/', 'src="../')
       filedata = filedata.replace('href=""', 'href="../index.html"')
   with open(path, 'w') as file:
       file.write(filedata)
  </code></pre>
  
  <p>And variable 'domain' in this exaple is: avium.pl</p>