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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:21:34+00:00 2026-05-26T10:21:34+00:00

In a particular example, I want to extract function calls in a string input

  • 0

In a particular example, I want to extract function calls in a string input (ruby script), to do some statistics (in java). For an example input of:

Math.sqrt(2-Math.hypot((3),4))-factorial(5)

I want to get a list of possible functions used (verification does not need to be 100% accurate, and it can include some extra faulty guesses) :

{ Math.sqrt, Math.hypot, factorial }

List does not have to be case sensitive, but it should include function class path if it exists.

I tried naively simplistic ".*\\((.*)\\)", but I could not get it to work. It seems, that I need to use lookaheads or backreference, but I’m a bit stumped. My question is, can I even do this?

  • 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-26T10:21:35+00:00Added an answer on May 26, 2026 at 10:21 am

    No. You cannot should not (see edit below) do this.

    Regular expressions can only match regular languages, but bracket () matching is required to match function calls since there can be nested expressions like ((1+ 2)*3) in a function call. Regular expressions cannot deal with nested parentheses.

    To learn more about regular languages and the limits of regular expressions, see Regular Expressions (wikipedia)

    To solve your particular problem, you might be interested in the following resources, which recommend importing the ruby script and using reflection (wikipedia)

    • Ruby Reflection
    • How to get argument names using reflection

    Edit: If all you want is the function name it is possible that you might get regex to work. However:

    • there are other problem cases. For example what would you do if a member function is called? a constructor?
    • if you ever want to scrape more information (such as arguments passed in) you will have to discard your project and start over.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert for example a particular date 12-11-2008 11:33:04.510 to UTC datetime.
I want to check a particular website from various locations. For example, I see
I want to extract rows from a file that match a particular pattern and
This particular example relates to Django in Python, but should apply to any language
How do databases (mySQL if a particular example is important) determine the size of
I'm reading the book LINQ Pocket Reference and there is a particular example (slightly
Occasionally I come accross a unit test that doesn't Assert anything. The particular example
Is there any way to retrieve all friends in a particular network? For example,
I'm new to unit testing and NUit in particular. I'm just typing some examples
I'm trying to extract an element with a particular innertext from a parsed XML

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.