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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:54:48+00:00 2026-05-16T15:54:48+00:00

I am a complete newb when it comes to regex, and would like help

  • 0

I am a complete newb when it comes to regex, and would like help to make an expression to match in the following:

 {ValidFunctionName}({parameter}:"{value}")

 {ValidFunctionName}({parameter}:"{value}",
                     {parameter}:"{value}")

 {ValidFunctionName}()

Where {x} is what I want to match, {parameter} can be anything $%”$ for example and {value} must be enclosed in quotation marks.

ThisIsValid_01(a:"40")

would be “ThisIsValid_01”, “a”, “40”

ThisIsValid_01(a:"40", b:"ZOO")

would be “ThisIsValid_01”, “a”, “40”, “b”, “ZOO”

01_ThisIsntValid(a:"40")

wouldn’t return anything

ThisIsntValid_02(a:40)

wouldn’t return anything, as 40 is not enclosed in quotation marks.

ThisIsValid_02()

would return “ThisIsValid_02”

For a valid function name I came across: “[A-Za-z_][A-Za-z_0-9]*”
But I can’t for the life of me figure out how to match the rest.
I’ve been playing around on http://regexpal.com/ to try to get valid matches to all conditions, but to no avail 🙁

It would be nice if you kindly explained the regex too, so I can learn 🙂

  • 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-16T15:54:49+00:00Added an answer on May 16, 2026 at 3:54 pm

    Someone else has already given an answer that gives you a flat list of strings, but in the interest of strong typing and proper class structure, I’m going to provide a solution that encapsulates the data properly.

    First, declare two classes:

    public class ParamValue         // For a parameter and its value
    {
        public string Parameter;
        public string Value;
    }
    public class FunctionInfo       // For a whole function with all its parameters
    {
        public string FunctionName;
        public List<ParamValue> Values;
    }
    

    Then do the matching and populate a list of FunctionInfos:

    (By the way, I’ve made some slight fixes to the regexes… it will now match identifiers correctly, and it will not include the double-quotes as part of the “value” of each parameter.)

    Regex r = new Regex(@"(?<function>[\p{L}_]\w*?)\((?<inner>.*?)\)");
    Regex inner = new Regex(@",?(?<param>.+?):""(?<value>[^""]*?)""");
    string input = "_test0(a:\"lolololol\",b:\"2\") _test1(ghgasghe:\"asjkdgh\")";
    
    var matches = new List<FunctionInfo>();
    
    if (r.IsMatch(input))
    {
        MatchCollection mc = r.Matches(input);
        foreach (Match match in mc)
        {
            var l = new List<ParamValue>();
    
            foreach (Match m in inner.Matches(match.Groups["inner"].Value))
                l.Add(new ParamValue
                {
                    Parameter = m.Groups["param"].Value,
                    Value = m.Groups["value"].Value
                });
    
            matches.Add(new FunctionInfo
            {
                FunctionName = match.Groups["function"].Value,
                Values = l
            });
        }
    }
    

    Then you can access the collection nicely with identifiers like FunctionName:

    foreach (var match in matches)
    {
        Console.WriteLine("{0}({1})", match.FunctionName,
            string.Join(", ", match.Values.Select(val =>
                string.Format("{0}: \"{1}\"", val.Parameter, val.Value))));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complete XML document in a string and would like a Document
What is the complete and correct syntax for the SQL Case expression?
So I am a complete newb, and am currently taking an intro to Mobile
Complete beginner here. I want to create a new tab on each page that
To complete some testing I need to load the 64 bit version of an
The complete warning is Validation (): Element 'html' occurs too few times This is
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
I'm a complete perl novice, am running a perl script using perl 5.10 and
I am a complete beginner trying to develop for FCKeditor so please bear with
We have an auto-complete list that's populated when an you send an email to

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.