You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Grafana变量中用Regex提取双命名捕获组?

Grafana下拉变量正则捕获方案

可以同时捕获text和value两个命名组,调整后的正则表达式如下:

^(?<value>.+\+(?<text>[^@]+)@.+)$

正则说明:

  • ^ 和 $:锁定整行匹配,避免截取邮箱的部分内容
  • (?<value>.+\+(?<text>[^@]+)@.+):把整个邮箱地址完整捕获为value组
    • 嵌套的(?<text>[^@]+):精准提取+符号之后、@符号之前的所有内容,作为text组

匹配结果验证:

对应你给出的测试邮箱:

  • development+info@example.com → text: info,value: development+info@example.com
  • production+errors@example.com → text: errors,value: production+errors@example.com
  • production+warnings@example.com → text: warnings,value: production+warnings@example.com

完全匹配你期望的捕获组对应关系。

内容的提问来源于stack exchange,提问作者Aaron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 07:25:23