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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:30:10+00:00 2026-06-02T16:30:10+00:00

im looking for way how to remove whole bodies from functions in some C

  • 0

im looking for way how to remove whole bodies from functions in some C source file.

For example I have file with this content:

1.  int func1 (int para) {
2.    return para;
3.  }
4.
5.  int func2 (int para) {
6.    if (1) {
7.      return para;
8.    }
9.    return para;
10. }

I have tried these regex:

content = re.sub('(\{[.*]?\})', '', content, flags=re.DOTALL)

But there is problem with nested { }. This regex substitute only to first }, so lines 9 and 10 are still in content. I think solution should be in counting { and } brackets and stop substitution when counter is on 0. { is found => counter++, } is found => counter–. But I have no idea how to implement this in python. Can u guys give me a kick?

  • 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-02T16:30:11+00:00Added an answer on June 2, 2026 at 4:30 pm

    I think you’re trying to re-invent a wheel that has already been implemented many times before. If all you want is to extract the signature of each function in a C file, there are much easier ways to do it.

    The ctags utility will take care of this for you:

    ~/test$ ctags -x --c-types=f ./test.c
    func1            function      1 ./test.c         int func1 (int para) {
    func2            function      5 ./test.c         int func2 (int para) {
    ~/test$ # Clean up the output a little bit
    ~/test$ ctags -x --c-types=f ./test.c | sed -e 's/\s\+/ /g' | cut -d ' ' -f 5-
    int func1 (int para) {
    int func2 (int para) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a way to remove some characters from the end of
I have been looking for a way to remove an attachment from Jira using
I'm looking for a way to add or remove files to/from an existing ZIP
I am looking for a way I can remove duplicate values from a PHP
I'm looking for a way to remove lines within multiple csv files, in bash
I am looking for a way to remove all <table*> <tr*> <td*> </td> </tr>
I'm looking for a simplest way to remove duplication in my WPF code. Code
I am looking for the fastest way to remove duplicate values in a string
I'm looking for a way to remove the background of a 24bit bitmap, while
I have an application that reads lines from a file and runs its magic

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.