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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:50:50+00:00 2026-06-07T20:50:50+00:00

I am fairly new into regexes, so I wrote the following simple regex using

  • 0

I am fairly new into regexes, so I wrote the following simple regex using positive lookahead that detects functions and function calls in a C source file-

\w+(?=\s*\()

It works fine, but the problem is it detects non-function syntaxes like if(), while()etc too.
I can easily avoid this by saying-

(if(?!\()) | (while(?!\())

But the problem is how to combine the second regex with the first one? I cant OR them, cos the first one still matches if(), while() etc and in an OR expression, its enough if one of the term matches.

How to combine these regexes or have a better simpler one which will not match non-function syntaxes like if(), while()

PS: I use the following tools to test my regexes

GSkinner

RegexPal

  • 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-07T20:50:51+00:00Added an answer on June 7, 2026 at 8:50 pm

    There are quite a lot of assumptions when you are searching for function call in C with regex. That aside, if you are happy with what is matched (there are valid function calls that will not be matched), and you want to exclude if and while from the result list, you can use the following regex:

    (?!\b(if|while|for)\b)\b\w+(?=\s*\()
    

    The regex uses word boundary \b to make sure that the whole name is matched (prevent partial matching of hile in while), and the whole name is not keyword (prevent rejection of whilenothinghappens).

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

Sidebar

Related Questions

I'm fairly new to using MSSQL and have run into a weird problem. Given
I'm fairly new to coding and just recently started working on integrating functions into
I am fairly new to XCODE development currently following several tutorials. Bumped into an
I am fairly new to python, and really new to regex! I am using
I am fairly new to asp.net and come into a problem whilst using a
I am fairly new to C++, but i have ran into an issue which
I fairly new to JQuery and perhaps trying to achieve something that might be
I'm fairly new to ruby and I've got a hash that looks like so:
I'm fairly new to Mvc and ran into a problem try to use an
I'm fairly new to Android development so I ran into a problem with 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.