I am trying to create a calculator,where operands are words.It can repeat any number of times.
e.g. EmpName+xyz or EmpName or x+rr+fff.
It should reject such pattern e.g.
EmpName+
I created a regular expression:
(?m)(?<Operand>^[a-z].*?)(?<Operator>[+*])
On this output:
1) a + b
2) ab+dddd
3) ab*fffff*ggggg
4) dfg+fg4444+fgf4
5) xxxxx
But it only targets 1,2,3,4 and up to only first operator. Output in regex 2.05.
"Operand: [ab]"
"Operator:[+]"
I am using regex builder 2.05 to test my regex. How i can repeat this pattern any number of times? Thanks in advance.
This would typically be expressed as
that is
(?m)<Operand>([+*]<Operator>)*Then I suggest considering using a real parser. The language of balanced parentheses is not regular.