I'm feeling so frustrated and lost right now. Any help you can offer would be greatly appreciated. I am currently dealing with an issue in Katex and Guppy keyboard. My goal is to create a regex that will identify the word matrix
, locate the slash
that has spaces before and after it, and then replace it with a double slash. However, the problem I am facing is that it keeps selecting all slashes between "matrix".
\left(\begin{matrix} \sqrt[ 5 ]{ 6 \phantom{\tiny{!}}} \ \dfrac{ 55 }{ 66 } \end{matrix}\right)
I need to work around ignoring instances of \sqrt
because the slash does not have spaces on both sides.
My desired outcome looks something like this:
\left(\begin{matrix} \sqrt[ 5 ]{ 6 \phantom{\tiny{!}}} \\ \dfrac{ 55 }{ 66 } \end{matrix}\right)
Below is the code I have been working on which is only partially functioning:
const regex = /matrix(.*?)\\(.*?)matrix/g;
equation = equation.replace(regex, 'matrix$1\\\\$2matrix');