Sample code in Latex:
%Chebyshev of second kind
egin{equation}
sum_{ell hiderel{=} 0}^nfrac{( ChebyU{ell}@{x} )^2}*{ frac{pi}{2} }*=frac{ 2^n }{ frac{pi}{2} 2^n+1 }frac{ ChebyU{n+1}@{x} ChebyU{n}@{y} - ChebyU{n}@{x} ChebyU{n+1}@{y} }{x-y}
end{equation}
frac{(ChebyU{ell}@{x})^2}*{frac{pi}{2}}
is the fraction I am looking at for this specific case. Since it is a fraction in the denominator of another fraction I would like to use Python regex to change this from a/(b/c)
to (ac)/b
.
Example output:
%Chebyshev of second kind
egin{equation}
sum_{ell hiderel{=} 0}^nfrac{(2 ChebyU{ell}@{x} )^2}{pi}*=frac{ 2^n }{ frac{pi}{2} 2^n+1 }frac{ ChebyU{n+1}@{x} ChebyU{n}@{y} - ChebyU{n}@{x} ChebyU{n+1}@{y} }{x-y}
end{equation}
End result: frac{(2ChebyU{ell}@{x})^2}{pi}
is the fraction that the regex should result in.
How would I go about doing this with regex in Python?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…