I have a some HTML text in mathjax format:
text = \"an inline \\\\( f(x) = \\frac{a}{b} \\\\) equation, a display equation \\\\[ F = m a \\\\] \\n and anothe
Try:
desired = text.gsub(/\\\[\s*(.*?)\s*\\\]/, "
")
desired = desired.gsub(/\\\(\s*(.*?)\s*\\\)/, "
")
desired
The important changes that had to happen:
gsub should be a regex (as Anthony mentioned)\\2 (instead of just \2) (see the rdoc)\There were a couple of other minor formatting things (spaces, etc).