Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6620281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:04:42+00:00 2026-05-25T21:04:42+00:00

I have a file, index.html , containing data like this: <li><a href=/battered-fried-chicken-breast-no-skin.html>battered fried chicken

  • 0

I have a file, index.html, containing data like this:

<li><a href="/battered-fried-chicken-breast-no-skin.html">battered fried chicken breast, no skin</a></li>
<li><a href="/bbq-short-ribs-with-sauce.html">bbq short ribs with sauce</a></li>
<li><a href="/bbq-spareribs-&-sauce-eat-lean-&-fat.html">bbq spareribs & sauce (eat lean & fat)</a></li>
<li><a href="/bbq-spareribs-&-sauce-eat-lean-only.html">bbq spareribs & sauce (eat lean only)</a></li>

I need to strip the & symbols from the URLs, such that "/bbq-spareribs-&-sauce-eat-lean-&-fat.html" becomes "/bbq-spareribs--sauce-eat-lean--fat.html". However, I do not wish to remove the & symbol from the parts of the file which are not URLs, such as the text of the link, bbq spareribs & sauce (eat lean & fat).

How would I accomplish this on a standard Linux install? It doesn’t matter to me what specific tool/language is used to achieve the result so long as it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:04:42+00:00Added an answer on May 25, 2026 at 9:04 pm

    If you’re happy to install BeautifulSoup, this simple Python script may do what you want:

    #!/usr/bin/evn python
    import sys
    from BeautifulSoup import BeautifulSoup
    
    soup = BeautifulSoup(sys.stdin.read())
    for a in soup.findAll("a"):
        a["href"] = a["href"].replace("&", "")
    
    print soup
    

    Example usage:

    [me@home]$ cat your.html | python amp_remover.py
    <li><a href="/battered-fried-chicken-breast-no-skin.html">battered fried chicken breast, no skin</a></li>
    <li><a href="/bbq-short-ribs-with-sauce.html">bbq short ribs with sauce</a></li>
    <li><a href="/bbq-spareribs--sauce-eat-lean--fat.html">bbq spareribs & sauce (eat lean & fat)</a></li>
    <li><a href="/bbq-spareribs--sauce-eat-lean-only.html">bbq spareribs & sauce (eat lean only)</a></li>
    

    Caveat: Since we’re regenerating the output HTML based on a parsed representation of it, the formatting may change. Other possible changes include the explicit closing of tags if your markup is not well formed.

    I may be wrong, but I suspect most solutions that use a proper XML/HTML parser will result in similar issues. To maintain the file exactly as it is and only remove the offending chars, you will have to end up using regex-based search and remove/replace. Many will advice against parsing XML/HTML with regex except for really trivial patterns. In your case, that may be true, but I’m yet to be convinced.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Absolute beginner question: I have a template file index.html that looks like this: ...
I have Javascript function defined in the main index.html file. One part of this
I have a file system structure with symlinks, something like this: folder123 index.php config.php
I'm writing on objective-C. I have WebView and local file index.html has <a href='http://www.google.com'
Simple question. I'm newbie on javascript and html. I have a file index.html like:
I have a static file called index.html that I'd like to serve when someone
I have the following file structure: |- index.html vendor |- jquery.min.js (some libraries) js
I have an upload script that write a index.html file, I modified it to
I have a PHP script (index.php) that includes an index.html file in a sub-directory
I have activated the IIS package for windows, and, I created an index.html file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.