Why /(word){0}/ does not work?
Why /(word){0}/ does not work?
am 12.11.2007 22:56:06 von chacallot
Hi,
I use a monitoring application, which allow use of perl regexp to
filter which instance of something I want to monitor.
In some case I want to monitor everything except one instance.
Lets say it's every filesystem except /temp.
The monitoring software allow perl regexp but not negating them.
So I tried /(\/temp){0}/ but it doesnt work (every filesystem is
monitored /temp included).
Why is it it doesnt work?
Is /^(?:(?!\/temp).)*$/ my only chance to do this right? Looks insanly
obfuscated to me, but if you this it's the rite way to do it, I may
try to understand it ....
Regards,
Chacallot.
Re: Why /(word){0}/ does not work?
am 12.11.2007 23:17:09 von jurgenex
chacallot@gmail.com wrote:
> So I tried /(\/temp){0}/ but it doesnt work (every filesystem is
> monitored /temp included).
The usual terminology for REs is "to match", not "to monitor". Therefore I
am not sure about if you are complaining that /(\/temp){0}/ matches '/temp'
or doesn't match '/temp'.
However, _I_ read /(\/temp){0}/ as zero consecutive matches of /(\/temp)/
which would match exactly the same strings as the empty RE //, e.g. it will
match every string.
> Why is it it doesnt work?
But it does work. It matches zero repetitions of the preceeding RE.
jue
Re: Why /(word){0}/ does not work?
am 13.11.2007 00:29:15 von Big and Blue
chacallot@gmail.com wrote:
> The monitoring software allow perl regexp but not negating them.
Does it allow you to set an action of "ignore"?
If so, set a regex for /temp - action == ignore
Then set a regex for the rest of life, doing what you want for it.
--
Just because I've written it doesn't mean that
either you or I have to believe it.
Re: Why /(word){0}/ does not work?
am 13.11.2007 02:28:53 von merlyn
>>>>> "chacallot" == chacallot writes:
chacallot> So I tried /(\/temp){0}/ but it doesnt work (every filesystem is
chacallot> monitored /temp included).
Indeed. The string "a" matches /a{0}/, because "a" has a match for zero
instances of 'a', which is the same as the empty string, which every string
has.
Why would you expect it to do something different?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Re: Why /(word){0}/ does not work?
am 14.11.2007 00:40:05 von rvtol+news
Randal L. Schwartz schreef:
> chacallot:
> chacallot> So I tried /(\/temp){0}/ but it doesnt work (every
> filesystem is chacallot> monitored /temp included).
>
> Indeed. The string "a" matches /a{0}/, because "a" has a match for
> zero instances of 'a', which is the same as the empty string, which
> every string has.
>
> Why would you expect it to do something different?
I actually like chacallot's train of thought. He/She wants the number of
(possible) matches to be 0.
0 * 0 = 0, so why is a beggar happy if there are zero days on which he
received zero Euros?
chacallot, did you try this? !/^\/temp\//
If your software only allows unnegated Perl /regexen/:
/^(?!=\/temp\/)/
--
Affijn, Ruud
"Gewoon is een tijger."