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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:18:26+00:00 2026-05-28T01:18:26+00:00

I have specific built in functions where admins can execute through a website. For

  • 0

I have specific built in functions where admins can execute through a website. For simplicity let’s pretend there are only 2 functions which are:

1) func1 "requires 2 paramters"

2) func2 "requires 3 paramters"

so I have a textbox where users can enter stuff like: I use ‘;’ to separate the parameters

func1 x; y;  //  func1(x,y) is more understandable. func1 takes two parameters

or

func2 1; 2+2; 4;  // note that func2 takes 3 parameters...

or even more complicated nested functions such as;

func2  x; func1 a; b; ; z ; // for example in this example 1st parameter  = x
                                                           2nd parameter = func1 a; b; // note this is a function
                                                           3rd parameter = z

with the help of jquery I can take advantage of it’s intellecence/autocomplete functions to make sure I type the name of the functions correctly.

now here is where I am stuck

I will like to inform to the user if he is missing to pass parameters on each function.

for example if the user types:

  func2 x; y;  

then I will like to inform him that func2 is missing a parameter.

I know that will be eassy the problem is if the user types something like:

 func2  x; func1 a; b; ; z ;

I have managed to solve this with c#. It is very eassy. the way I do it is by start looking for functions from right to left. so if I do so the first function that I will find is func1 right? then I will more right until I find two ;’s if I replace that then I will have: func2 x; <temp> ; z ; note I replaced func1 a; b; with then I can continue doing the same thing and I will then find func2 and select until the 3rd ;’s

the problem is that if I create a regular expresion I don’t know how to start looking from right to left. If I were to start looking from left to right like it is the default then func2 will have it’s first paramter = x, it’s second paramter = func1 a, and it’s 3rd parameter = b. and that is not the case. If on the other hand I start doing the same thing from right to left everything works 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-28T01:18:26+00:00Added an answer on May 28, 2026 at 1:18 am

    So the hard part is going right to left? Use split regex and then reverse

    var valid_functions = ["func1","func2"]
    var valid_params = [4,1]
    
    var f_regex = new RegExp("\\b("+valid_functions.join("|")+")\\b");
    var f_data = "func2  x; func1 a; b; ; z ;".split(f_regex).reverse();
    for(var i=0;i<f_data.length;i+=2){   
        if(f_data[i] === ""){continue}  
        var f_name = f_data[i+1],
            f_params = f_data[i];    
        var pos = valid_functions.indexOf(f_name);
        if( f_params.split(";").length-1 !== valid_params[pos]){
            alert("Wrong number of arguments for " + f_name)
        }
    }
    

    Example of function with incorrect number of parameters: http://jsfiddle.net/tHcYM/1/

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

Sidebar

Related Questions

I have a project built and packaged with a specific version of jsp-apiand servlet-api
I have a specific DB2 query, and I would like to execute this query
I've built a number of work-specific helper functions that could be useful for other
Why doesn't the STL string class have an overloaded char* operator built-in? Is there
I have a utility build script that gets called from a variety of project-specific
I have projects that need to be build with a specific version of the
I have a specific changeset that I want to rollback my Development branch to,
I have a specific case in mind, but the question applies in general too.
I have a specific requirement that all children of a particular JComponent have double
I have a specific question, that could use a general answer... When building Multi-Tier

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.