I'm working with the Dynamic Disk Monitor in SiteScope and I need a regex that exclude the word "Harddisk" and the character "D".

So far, I found this:

^(?!.*Harddisk).*/percent full

How do I add the part for the exclusion of "D" in the same expression? I tried this and didn't work:

^(?!.*Harddisk|^D).*/percent full

More details:

This expression brings the percent full of all the Disks that the server has:

/.*/percent full/

This exclude all the disk that its name start with "Harddisk":

/^(?!.*Harddisk).*/percent full/

What I need is to improve the last expression for exclude all the "Hard Disk" and besides, the disk "D".

Thank you in advance for your help.

Regards, Estrella.

share|improve this question
    
Did you try ^(?!.*Harddisk|D)? – lurker Jan 9 '14 at 19:26
    
It was the first thing that I tried :( – e.vejar Jan 9 '14 at 19:45
    
I tried it ($my_var =~ /^(?!.*Harddisk|D)/) and it worked OK for me. – lurker Jan 9 '14 at 20:02

You can try this:

^(?>[^HD/]++|\BH|H(?!arddisk)|/(?!percent full))+/percent full

(Don't forget to escape the slash if needed)

share|improve this answer
    
I tried it and says that the expression has an error. – e.vejar Jan 9 '14 at 19:47

Perhaps the following will be helpful:

use strict;
use warnings;

while (<DATA>) {
    print if !/(?=.*\bHarddisk\b)(?=.*\bD\b)/;
}

__DATA__
Harddisk A
disk D
Harddisk D

Output:

Harddisk A
disk D

The expression evaluated by if has the following form: !(x and y).

share|improve this answer

Keep it simple.

m{/percent full} && !/\bHarddisk\b/ && !/D/
share|improve this answer
up vote 0 down vote accepted

A coworker helped me and found the answer and I wanted to share it with you:

/^(?!.*[E])^(?!.*(HarddiskVolume)).*/percent full/

I hope this helps.

Thanks to everyone who answered this!

-Estrella

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.