Regex to match LaTeX equations

前端 未结 1 1377
情话喂你
情话喂你 2021-02-04 13:50

I am trying to configure the TeXWorks editor to use the same syntax coloring as TeXMaker. However, TexWorks uses regexes to specify what should be coloured. Unfortunately it doe

1条回答
  •  我在风中等你
    2021-02-04 14:37

    Try this PCRE regex:

    (?

    See this regex in action: https://regex101.com/r/wP2aV6/25

    Since this regex uses recursion it will handle nested mathematical expressions correctly.

    This works only on PCRE compatible regex engines. It requires some advanced features of regex engines, like negative lookbehind, conditional expressions and recursion which are not present in all regex engines.

    Unless you need something really simple then I would advise against using this regex and instead using a proper LaTeX parser.

    0 讨论(0)
提交回复
热议问题