I have a program in which the user can input various values, amongst which square root values. I've tried designing a system where if the user inputs sqrt(number), then the program will extract the number, then do Math.Sqrt() on that number, and then pass it back.
The main problem arises when the theoretical possibility of something like Sqrt(4) / Sqrt(5) comes along. Because then not only am I dealing with one sqrt() statement, but I have to deal with the second as well.
The pattern I've been using for Regex is this:
string Pattern = @"sqrt\((.*)\)";
How can I modify this pattern to allow for the possibility of multiple square roots due to fractions?
I was also told to perhaps look into creating a parser for this. Would this be an appropriate solution?