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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:55:43+00:00 2026-05-31T23:55:43+00:00

I need the regex to find function calls in strings in php, I have

  • 0

I need the regex to find function calls in strings in php, I have tried to search here on stackoverflow but none of the ones i’ve tried worked.

this pattern: ^.*([\w][\(].*[\)])

This will match: functionone(fgfg) but also functionone(fgfg) dhgfghfgh functiontwo() as one match. Not 2 separate matches (as in functionone(fgfg) and functiontwo().

I don’t know how to write it but I think this is what I need.
1. Any string, followed by (
2. Any string followed by )

And then it should stop, not continue. Any regex-gurus that can help me out?

  • 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-31T23:55:44+00:00Added an answer on May 31, 2026 at 11:55 pm

    I see 5 issues with your regex

    1. If you want to match 2 functions in the same row, don’t use the anchor ^, this will anchor the regex to the start of the string.

    2. You then don’t need .* at the start maybe more something like \w+ (I am not sure what the spec of a function name in PHP is)

    3. if there is only one entry in a character class (and its not a negated one), you don’t need the character class

    4. The quantifier between the brackets needs to be a lazy one (followed by a ?). So after this 4 points your regex would look something like

      \w+\(.*?\)
      
    5. Is a regex really the right tool for this job?

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

Sidebar

Related Questions

Ok so I have a regex and I need it to find matches in
I have a set of strings and I need to find all all of
Couldn't find a function for this. I'm assuming I need to use regex? I'm
I need help in constructing RegEx for the search function on my website. I
I need to find a reliable method to search for Arabic words using PHP.
I need to do a regex find and replace on all the files in
I need to find picture location in HTML text based on regex. e.g. The
I'm doing some url rewriting in PHP and need to find URLS with a
I have an array of phone numbers and I need to find if a
I have a text that is a source-code file, I need to find 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.