I have a mathparser that can do functions like "IntPow(3,2)". If a user pastes "1,000,000" and then adds a plus symbol, making the full equation "1,000,000+IntPow(3,2)" the parser fails because it does not work with numbers that contain commas.
I need to remove the commas from the "1,000,000", but not from the "IntPow(3,2)" because IntPow has two parameters separated by a comma. The final equation will be "1000000+IntPow(3,2)". The equation is stored in one string. How would I remove only the commas that are outside of parenthesis? I'm assuming and saying that numbers that contain commas will not be placed inside the IntPow parameters list.
When I say "remove commas" I really mean remove "CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator" which could be a comma or a period depending on the local. This part will be easy because I assume regex will be used and I can just concatentate that value in the regex comma place.
I have this regex: (.*?) for finding the parenthesis and values inside of them but I'm not sure how to only remove the commas outside of the regex matches.
Any help would be greatly appreciated.
Thank you,
John