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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:15:11+00:00 2026-05-14T20:15:11+00:00

I am trying to properly extract methods definitions that are generated by comtypes for

  • 0

I am trying to properly extract methods definitions that are generated by comtypes for Com Interfaces using a regex. Furthermore some of them are blank which causes even more problems for me.

Basically i have this:

IXMLSerializerAlt._methods_ = [
    COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString',
              ( ['in'], BSTR, 'XML' ),
              ( ['in'], BSTR, 'TypeName' ),
              ( ['in'], BSTR, 'TypeNamespaceURI' ),
              ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )),
]

class EnvironmentManager(CoClass):
    u'Singleton object that manages different environments (collections of configuration information).'
    _reg_clsid_ = GUID('{8A626D49-5F5E-47D9-9463-0B802E9C4167}')
    _idlflags_ = []
    _typelib_path_ = typelib_path
    _reg_typelib_ = ('{5E1F7BC3-67C5-4AEE-8EC6-C4B73AAC42ED}', 1, 0)

INumberFormat._methods_ = [
]

I want to extract both the IXMLSerializerAlt and INumberFormat methods definitions however i cant figure out a proper regex. E.g. for IXMLSerializer i want to extract this:

IXMLSerializerAlt._methods_ = [
    COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString',
              ( ['in'], BSTR, 'XML' ),
              ( ['in'], BSTR, 'TypeName' ),
              ( ['in'], BSTR, 'TypeNamespaceURI' ),
              ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )),
]

This regex in my mind this should work:

^\w+\._methods_\s=\s\[$
(^.+$)*
^]$

Im checking my regex’s using kodos however i cannot figure out a way to make this work.

  • 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-14T20:15:12+00:00Added an answer on May 14, 2026 at 8:15 pm

    You’re missing the newline characters between $ and ^, and may not be using the re.MULTILINE flag which allows those to anchor at the start and end of lines. The following (compiled with re.MULTILINE) would match:

    \w+\._methods_\s=\s\[$(?:\n^.+$)*\n^\]$
    

    However, here’s a slightly simpliifed regex that will also match your examples:

    >>> s = '''...\nIXMLSerializerAlt._methods_ = [\n    COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString',\n              ( ['in'], BSTR, 'XML' ),\n              ( ['in'], BSTR, 'TypeName' ),\n              ( ['in'], BSTR, 'TypeNamespaceURI' ),\n              ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )),\n]\n...'''
    >>> import re
    >>> re.findall(r'^\w+\._methods_\s=\s\[$.*?^\]$', s, re.DOTALL | re.MULTILINE)
    ["IXMLSerializerAlt._methods_ = [\n    COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString',\n              ( ['in'], BSTR, 'XML' ),\n              ( ['in'], BSTR, 'TypeName' ),\n              ( ['in'], BSTR, 'TypeNamespaceURI' ),\n              ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )),\n]"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.