I’m trying to create a regex which will match either one of the following –
FVAL(A)
FVAL("A")
FVAL(A,B)
FVAL("A",B)
FVAL("A","B")
FVAL(A,"B")
FVAL(A,B,C)
FVAL("A",B,C)
FVAL("A","B",C)
FVAL("A","B","C")
FVAL("A",B,"C")
FVAL(A,"B","C")
Regex –
FVAL\s*\(\s*["*]\s*\w+\s*["*]\s*,*\s*["*]\s*\w+\s*["*]\s*,*\s*,*\s*["*]\s*\w+\s*["*]\s*\)
This regex is supposed to return all and any form of the function that is used.
For e.g. –
If match string were – FVAL(A,"B")+5 then match group should be FVAL(A,"B")
P.S. – I’m ignoring white spaces in match string, but they can be there.
Your expression is way too complicated.
Breakdown:
FVAL # "FVAL" \( # "(" "? # an optional double quote \w+ # at least one word character "? # an optional double quote (?: # group , # a comma "?\w+"? # quote - word character - quote ){0,2} # end group, repeat 0-2 times \) # ")"Insert whitespace
\sinto the expression where you see fit.