打开和关闭标签正则表达式

时间:2018-07-16 15:41:43

标签: regex tags latex matching

我一直在寻找能执行以下操作的Regex表达式:

找到图案:

for i in {1..1000}; do curl -s -o /dev/null -w "%{time_total}\n" http://server/get_things; done
  • 包括美元符号
  • 表达式中可能还有其他$$ some text $$. ,但它只应与开头$的开头$$匹配
  • 文本中可能多次出现这种模式,应该都可以识别。

示例:

$$

有人知道这个公式吗? 非常感谢!

1 个答案:

答案 0 :(得分:1)

您可以使用以下正则表达式:

\$\$.*?\$\$
  • \$\$匹配两个\$字符。
  • .*?尽可能少匹配任何内容。
  • \$\$匹配两个\$字符。

因此,匹配项为:

  • $$x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$$
  • $$ \frac{-b \pm \sqrt{b^2-8b}} $$
  • $$x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$$
  • $$ \frac{-b \pm \sqrt{b^2-8b}} $$
  • $$ hey $$

您可以实时测试正则表达式here