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

  • Home
  • SEARCH
  • 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 6242373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:56:33+00:00 2026-05-24T11:56:33+00:00

Best Solution i come up with so far, given a textblock it finds those

  • 0

Best Solution i come up with so far, given a textblock it finds those methods that have paramters, but also the function with parameter key like this: “get: function(key)”.

    public class JavaScriptMethodFinder
{
    static readonly string pattern = @"(?<=\s(?<Begin>[a-zA-Z_][a-zA-Z0-9_]*?)\(|\G)\s*((['""]).+?(?<!\\)\2|\{[^}]+\}|[^,;'""(){}\)]+)\s*(?:,|(?<IsEnd>\)))";
    private static readonly Regex RegEx = new Regex(pattern, RegexOptions.Compiled);

    public IEnumerable<dynamic> Find(string text)
    {
        var t = RegEx.Matches(text);
        dynamic current = null;
        bool isBegin;
        foreach (Match item in t)
        {

            if (isBegin = (item.Groups["Begin"].Value != string.Empty))
            {
                current = new ExpandoObject();
                current.MethodName = item.Groups["Begin"].Value;
                current.Parameters = new List<string>();
                current.Parameters.Add(item.Groups[1].Value);
            }else
                current.Parameters.Add(item.Groups[1].Value);
            if (item.Groups["IsEnd"].Value != string.Empty)
            {
                isBegin = false;
                if(!(item.Groups["Begin"].Value != string.Empty))
                    current.Parameters.Add(item.Groups[1].Value);
                yield return current;
            }

        }

    }

}

I wanna find Methods and its Variables. Given two examples.

First Example

function loadMarkers(markers)
{
     markers.push(
            new Marker(
              "Hdsf", 
              40.261330438503,
              10.4877055287361,
              "some text"
            ) 
      );
}

Second Example

var block = new AnotherMethod('literal', 'literal', {"key":0,"key":14962,"key":false,"key":2});

So far i have, tested here: http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx

(?<=Marker\(|\G)\s*((?<name>['""]).+?(?<!\\)\2|\{[^}]+\}|[^,;'""(){}\)]+)\s*(?:,|\))

Found 5 matches:
“Hdsf”, has 2 groups:
“Hdsf”
”
40.261330438503, has 2 groups:
40.261330438503
10.4877055287361, has 2 groups:
10.4877055287361
“some text” ) has 2 groups:
“some text”
”
) has 2 groups:

(?<=AnotherMethod\(|\G)\s*((?<name>['""]).+?(?<!\\)\2|\{[^}]+\}|[^,;'""(){}\)]+)\s*(?:,|\))

Found 3 matches:
‘literal’, has 2 groups:
‘literal’
‘ (name)
‘literal’, has 2 groups:
‘literal’
‘ (name)
{“key”:0,”key”:14962,”key”:false,”key”:2}) has 2 groups:
{“key”:0,”key”:14962,”key”:false,”key”:2}
(name)

I would like to combine it such that i have one expression

  • Match<(methodname)>
    • Group : parameter
    • Group : parameter
    • Group : parameter
  • Match<(methodname)>
    • Group : parameter
    • Group : parameter
    • Group : parameter

so when i scan a page which contains both cases, i will get two matches witch
ect the first capture being the method name and then the following is the paramters.

I been trying to modify what i already have, but its to complex with the LookBehind stuff for I to understand it.

  • 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-24T11:56:34+00:00Added an answer on May 24, 2026 at 11:56 am

    Regex’s are a very problematic approach for this type of project. Have you looked at using a genuine JavaScript parser/compiler like Rhino? That will give you full awareness of JavaScript syntax “for free” and the ability to walk your source code meaningfully.

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

Sidebar

Related Questions

What's the best solution for authoring HTML5 in Emacs? Is there a mode that
I am trying to come up with the best solution for creating a hierarchical
EDIT: So far, the best I've been able to come up with is a
Our program so far: We have a process that involves multiple schemata, orchestrations and
I have a client/server question that i am trying to figure out the best
best solution for use access in project for database with security i need to
What is the best solution for maintaining backup and revision control on live websites?
What is the best solution for converting WAV files to WMA (and vice versa)
What is the best solution to sanitize output HTML in Rails (to avoid XSS
A) What is the best solution for regularly backing up large PostgreSQL database (version

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.