title: How do you split in beautiful soup based on two parameters - python
body: <p>I am using beutifulsoup to extract the address of images in a documents. The links in the document however need cleaning, (specifically most images have links like /image.jpg&amp;randomtext and I want in formation <a href="https://www.webaddress.com/image.jpg&amp;filetype=l" rel="nofollow">https://www.webaddress.com/image.jpg&amp;filetype=l</a>"
  for this I currently use the code below:</p>
  
  <pre><code>    from bs4 import BeautifulSoup 
  
      c = ' &lt;html&gt;
              &lt;img src="/url/urls.do?filename=SWC.jpg&amp;filetype=h" width="300" height="300" alt="imagesk"/&gt;
              &lt;img src="/url/urls.do?filename=SWC.JPG&amp;filetype=h" width="300" height="300" alt="imagesk"/&gt; '
  
      soup = BeautifulSoup(c)
      link = [x['src'] for x in soup.findAll('img')]                                  
      link = [link_temp.split('.jpg')[0] for link_temp in link]                       
      full_images_links = ["https://www.webaddress.com" + linktemp + ".jpg&amp;filetype=l" for linktemp in link]  
  </code></pre>
  
  <p>this basically searches for all the linked images that end in .jpg, removes the content after it (lots of random codes), and then formats in way I can get the images. </p>
  
  <p>This works fine when the images has got the extension ".jpg", however does not when it has the extension ".JPG" </p>
  
  <p>For the above example, the desired output for the first image file works fine and gives:</p>
  
  <pre><code>  https://www.webaddress.com/url/urls.do?filename=SWC.jpg&amp;filetype=l
  </code></pre>
  
  <p>however the second one, the code comes out as</p>
  
  <pre><code>  https://www.webaddress.com/url/urls.do?filename=SWC.JPG&amp;filetype=h.jpg&amp;filetype=l
  </code></pre>
  
  <p>because it does split based on the capitalized ".JPG"</p>
  
  <p>I am ideally looking for something that could be extended to work with different formats (e.g. may run into .JPEG, .jpeg etc)</p>