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 8391965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:23:45+00:00 2026-06-09T19:23:45+00:00

i have converted the word file in to html file, but there is a

  • 0

i have converted the word file in to html file, but there is a problem, the MS-word automatically adds some style to the pages.

for example

<div align="center"></div>
<p style=""></p>
<table cellpadding="0">

<tr><img src="...."></img></tr>

</table>

i want to output to be as

 <div></div>
<p></p>
<table>

<tr><img src="...."></img></tr>

</table>

i dont want the img inline styles to be removed.

thanks in advance

update:  if it is very hard to keep img style in the file. please give me the code excluding that part. it is very urgent for me and i cant edit 1000 pages manually 
  • 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-06-09T19:23:47+00:00Added an answer on June 9, 2026 at 7:23 pm

    If you want to remove styles for a known list of tags, I don’t think its necessary to use a full weight HTML parser. Something like

    expr = r'((?<=<div)|(?<=<p))[ ]+.*?>'
    html_text = re.sub(expr,'>',html_text)
    

    works just fine. Of course, you would use an array of tags you want to replace to generate the (?<=

    If you have a list of style tags that you want to remove, it’s even easier. Just generate an expression like

    expr = r' (style|align|myStyleTag)=".*?"'
    

    with re.sub.

    If you need a dynamic combination thereof, use a parser.

    Edited in response to comments by OP:

    Unfortunately, lookbehind needs fixed-size expressions, so <.* or similar won’t work. If you don’t have a fixed tag list, it’s probably better to use a preexisting framework.

    An ugly way around this would be something like:

    expr = "("
    for i in range(1,8): ## or whatever the max/min tag lengths are
        expr += "(?<=<[a-zA-Z]{" + str(i) + "})|"
    expr = expr[:-1] + ")[ ]+.*?>"
    

    But that’s pretty bad style.

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

Sidebar

Related Questions

I have a file that was converted from EBCDIC to ASCII. Where there used
I have converted ILColorPicker to work on XCode4 and Storyboard. My problem is that
Using explode i have converted the string into array , But the array look
I am very new to WordPress. I have converted a HTML website I created
I have a word file () which has many text fields and a startup
Here is what I did: 1. I have a template WORD file that can
I need to convert a Word document into HTML file(s) in Java. The function
I have an word document which I want to convert to text (.txt) file
I have a number of word documents that I'd like to remove some elements
I have an application need to print a MS Word .docx file from the

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.