I have the following string:
function(param1, param2, param3, param4, ..., paramN)
I need a Regex code to parse it as an array of strings:
function
param1
param2
param3
param4
.
.
.
paramN
I've tried several examples in the net but none of them seems to work for me.
[EDIT]
Not woking with the suggestion. Check the above code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace TestRegex
{
class Program
{
static void Main(string[] args)
{
string Expression = String.Empty;
while (Expression.Trim() != "EXIT")
{
Expression = Console.ReadLine();
///
/// Get function name
///
var funcTags = Regex.Matches(Expression, @"b[^()]+\((.*)\)$");
Console.WriteLine("Matches: " + funcTags.Count);
foreach (var item in funcTags)
Console.WriteLine("FuncTag: " + item);
///
/// Get parameters
///
var paramTags = Regex.Matches(Expression, @"\b[^()]+\((.*)\)$");
Console.WriteLine("Matches: " + paramTags.Count);
foreach (var item in paramTags)
Console.WriteLine("ParamTag: " + item);
}
}
}
}
Output:
function("a", "b", "c");
Matches: 0
Matches: 0
Something is wrong here... Appreciate help.