I have let’s say this string:
“A = Beta * C / Delta + 2”;
Now I want to replace all the variables(A, Beta, C, Delta) with the same name but with a prefix before it, like “x”. So it would become:
“xA = xBeta * xC / xDelta + 2”;
Maybe my head is just tired, but I can’t think of a solution for this.
To find matches, it’s easy, just test against /[a-zA-Z]+/ regex, but how in javascript should I get what I found and replace it easily not using multiple function calls?
Try this:
Results in: