-1

I’m using grafana to get zabbix agent data.

I need to match only one of these following values:

Free space on C: (Percentage)

Free Space on / (Percentage)

This expression doesn’t let match the second one:

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

Even in online regex text doesn’t match as well.

I’m pretty sure the problem is with the character /.

Community
  • 1
  • 1
Sini
  • 1
  • Shouldn't match any of them. You'll have to escape the parentheses. [Check this](https://regex101.com/r/554v7v/1) – SamWhan Apr 24 '18 at 12:05

3 Answers3

0

What about if you escape the forward slash with a forward slash, like this?

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

Demo

Matt.G
  • 3,586
  • 2
  • 10
  • 23
Tony
  • 460
  • 1
  • 7
  • 20
0

Try this:

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

Demo

Matt.G
  • 3,586
  • 2
  • 10
  • 23
0

To match one of your values you have to escape \ the parenthesis around (Percentage)

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

If you only want to match your values might use a non capturing group ^(?:

The fourth bird
  • 154,723
  • 16
  • 55
  • 70