locked
search and replace using python-docx library RRS feed

  • Question

  • i would like to search a word and replace it with table. the following code is just for strings:

    def paragraph_replace(self, search, replace):
        searchre = re.compile(search)
        for paragraph in self.paragraphs:
            paragraph_text = paragraph.text
            if paragraph_text:
                if searchre.search(paragraph_text):
                    paragraph.text = re.sub(search, replace, paragraph_text)
        return paragraph_text

    is there a way of replace it with table?

    Sunday, July 20, 2014 7:45 PM

All replies

  • Hi,

    As far as I know, Python-Docx Lib is an open source lib which has nothing to do with Office Object Model. It's processing OpenXML directly. So I'm afraid this is not a proper forum for your question.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 21, 2014 11:34 AM