POV-Ray : Newsgroups : povray.off-topic : Other people dislike regexes too : Re: Other people dislike regexes too Server Time
29 Jul 2024 02:30:51 EDT (-0400)
  Re: Other people dislike regexes too  
From: Invisible
Date: 17 Jul 2012 04:36:50
Message: <50052422$1@news.povray.org>
On 17/07/2012 07:28 AM, Warp wrote:
> Invisible<voi### [at] devnull>  wrote:
>> In my limited experience, people don't use regexes for simple pattern
>> matches.
>
> Yes, because you have decades of extensive experience on how eg. unix users
> typically use regexes.

Perhaps you mean like

   grep -e "ntpd\[[[:digit:]]\+\]" /var/log/messages.4

which obviously searches for... wait, what does it search for exactly?

So how about this?

   egrep 
'\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'

Yeah, that's pretty clear. If by "clear" you mean "it's going to take me 
five minutes to figure out exactly what this is supposed to do".

Or how about

   dmesg | egrep '(s|h)d[a-z]'

At least that one only takes a minute or two to figure out.

And then we come to horrifying things such as

while(<STDIN>)
   {
   my($line) = $_;
   chomp($line);
   if($line !~ /<DIR>/)
     {
     if ($line =~ /.{28}(\d\d)-(\d\d)-(\d\d).{8}(.+)$/)
       {
       my($filename) = $4;
       my($yymmdd) = "$3$1$2";
       if($yymmdd lt "971222")
         {
         print "copy $filename \\oldie\n";
         }
       }
     }
   }

I don't even want to contemplate what the hell that does...

Still, I suppose the fact that you can do bad things with regexes 
doesn't automatically mean that regexes are bad.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.