You can use negative lookahead assertions to make sure that the characters you are capturing isn't purely digits. Try this:
^[\w]+ (?!\d+\()([\w]+)\((?:(?!\d+[,\)])(\w+)),(?:(?!\d+[,\)])(\w+))\)$
Demo here.
keyword input(param_input,param_input2) -> Will match
keyword 12345(param_input,param_input2)
keyword in123(abc123_DEF4,a1_b2_C3_d45) -> Will match
keyword input(12345678901,param_input2)
keyword input(param_input,123456789012)
keyword input(12345678901,123456789012)
keyword XYZ98(aaaa1111BB2,CCCCCCC33333) -> Will match
keyword XYZ98(aaaa1111BB2,CCCCCCC33333,DD44)
Where:
^[\w]+
- Match the initial string e.g. keyword
(?!\d+\()([\w]+)\(
- Using a negative lookahead assertion, match the next part until (
only if it isn't purely digits e.g. input(
but not 12345(
(?:(?!\d+[,\)])(\w+)),
- Again using a negative lookahead assertion, match the next part until ,
only if it isn't purely digits e.g. param_input,
but not 12345678901,
(?:(?!\d+[,\)])(\w+))\)$
- Again using a negative lookahead assertion, match the next part until the ending )
only if it isn't purely digits e.g. param_input2)
but not 123456789012))
This is fixed to 2x input parameters e.g. (param_input,param_input2)
. Note that if you wish to accept variable amount of input parameters e.g. (param1,param2,param3,...,paramN)
, you can't easily do it with regex groups as explained in this answer from another thread.
- What you can do instead is manually define this
(?:(?!\d+[,\)])(\w+)),
for every additional parameter.
References: