0

I am trying to convert a Word document to HTML that I can directly use on my website. Because the document has some certain patterns, so I've decided it is easier to use wildcard replacing method than some word-to-html conversion or build-in "save as html" tool.

So in this document, all paragraphs with 20pt font size is used for subtitles, I want to wrap them with tag. Using "find by format", I was able to find all characters with 20pt, but I couldn't find out how to save these matches to variables so I can replace them using something like <h3>\1</h3>. (*) doesn't work because it will only match one character instead of the whole paragraph due to Word's lazy match pattern. enter image description here

1
  • I've decided it is easier to use wildcard replacing method than some word-to-html conversion or build-in "save as html" tool., good luck!
    – Toto
    Dec 30, 2020 at 8:59

2 Answers 2

1

I believe this should do what you want. My example shows it searching not only for a 20pt font paragraph of text but also the paragraph’s Style Name. If you know all of these heading paragraphs are a specific style, the you can just use the style name and not worry about the font size.

Additionally, the Replace is setup to replace the paragraph mark with the ending HTML string.

enter image description here

1

I had a VERY similar problem - need to replace blocks of text of a certain style with their own content but with tags around it (similar to your problem).

It turns out that you don't need to use wildcards at all!

Instead, simply specify the style/font size you wish to find-and-replace, then in the Replace With: diaglogue ...

  1. use the special replacement character sequence ^& to represent the found text (equivalent to \1 in wildcards kind of), so in your case the replacement string would be <h3>^&</h3>
  2. choose Default paragraph font as the font styling for the replacement text.

Sucks so bad that I'm unworthy of being allowed to paste a picture - you'll have to click here to see the beautiful illustration I prepared

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.