Converting LaTeX expression to infix expression
Asked Answered
T

1

6

Let us assume we have an expression in LaTeX form:

var latex =\frac{x}{\frac{y}{y}}

So output required is:

output= (x)/((y)/(y));

I tried out an example as stated in the link: Convert LaTeX to dynamic Javascript function but I am getting the output of the above latex as:

(x)/(\frac{y){y}}`

How can I get the expression converted properly? Thanks in advance!

Tripper answered 23/7, 2015 at 12:53 Comment(0)
V
2

solution of the above problem

var func = '\frac{x}{\frac{y}{y}}';
func = func.replace(/}{/g, ")/(").replace(/\frac{/g, "(").replace(/}/g, ")")
console.log(func);
  1. innput = \frac{x}{\frac{y}{y}}
  2. output = (x)/((y)/(y))
Vehemence answered 28/7, 2015 at 11:31 Comment(1)
Thank you !The best solution till now!Tripper

© 2022 - 2024 — McMap. All rights reserved.