ruby regexp to replace equations

后端 未结 2 683
轻奢々
轻奢々 2021-01-18 19:41

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         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-18 20:30

    Not sure if your regexp is right - but in Ruby, Regexp are delimited by //, try like this :

    desired = text.gsub(/(\\[)(.*?)(\\])/, "")
    

    You were trying to do string substition, and of course gsub wasn't finding a string containing (\\[)(.*?)(\\])

提交回复
热议问题