i have a string to be used for latex later the string is... roughly
$string = "\\sin\\left(x\ight)^{2}";
where the sin could also be cos, tan, sec, log, etc.. the exponent could also be any integer, float or variable, the argument could be anything..
I would like a regex function that turns it into
$string = "\\sin^{2}\\left(x\ight)";
or more generally
generalstring = "f(t)^{n}";
to be turned into "f^{n}(t)";
my apologies in advance, i have a feeling this should be extremely easy to do, I'm just learning this.
oh also i would like to restric this to only strings with trig functions logs and some other ones where my functions are not printing correctly.