regex - 正则表达式: how to deal with character/

标签 regex linux debian grafana zabbix

我正在使用grafana获取zabbix代理数据。

我只需匹配以下值之一:

Free space on C: (Percentage)

Free Space on / (Percentage)

该表达式不允许与第二个表达式匹配:

/^(Free space on C: (Percentage)|Free Space on \/ (Percentage))$/

即使在在线正则表达式文本中也不匹配。

我很确定问题出在字符/上。

最佳答案

试试这个:

/^Free [Ss]pace on (?:C:|\/) \(Percentage\)$/gm

Demo

关于regex - 正则表达式: how to deal with character/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50001024/

相关文章:

linux - 如何更改 Apache 中包的路径?

javascript - 正则表达式匹配不输出相邻匹配javascript

linux - 查找 IBM MQ 队列管理器的端口号

linux - 在获取 .bashrc 后,如何在使用 ssh 登录时在远程执行命令?

Linux shell 脚本 : Allow user to use variables in input

linux - 无法重新启动 webmin [状态 2]

linux - 我在 ubuntu 中更新和安装新 paquet 时遇到问题

java - 在正则表达式 java 中获取括号内的文本以及分隔符?

Python 重新匹配如果不是子串

java - 获取 java.util.regex.PatternSyntaxException : Illegal repetition when trying to replace String with replaceAll()