POV-Ray : Newsgroups : povray.off-topic : Other people dislike regexes too Server Time
29 Jul 2024 06:15:52 EDT (-0400)
  Other people dislike regexes too (Message 11 to 20 of 32)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Invisible
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 04:40:35
Message: <50052503$1@news.povray.org>
On 17/07/2012 09:21 AM, Warp wrote:
> Invisible<voi### [at] devnull>  wrote:
>> And yet, this seems to be how people almost always try to use regexes...
>
>    No, it isn't.

That would explain why the question "how do I parse XHTML with a regex?" 
is so common on Stack Overflow that a guy actually lost his mind trying 
to answer it.

Actually, no it wouldn't.


Post a reply to this message

From: Warp
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 05:40:57
Message: <50053328@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> 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

You don't seem to grasp what "the most common usage" means. It does not
mean "the most prominent examples displayed on webpages" or "the most
prominent examples that I have seen". It means the forms that people
*most commonly* use, as in raw numbers. Count how many people use a
completely syntax-less regex or with just a simple wildcard, vs. the
times when someone has to write a really large and complex expression.
I'd estimate that the former wins about a million to one.

> Or how about

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

If you want to build your straw man, at least use examples that conform
to your straw man. That's a bad example because it can be understood in
about 2 seconds.

> 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";
>          }
>        }
>      }
>    }

Also, if you are building your straw man, at least try to use actual
regexes and not some unrelated scripting language.

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 05:41:54
Message: <50053362@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> On 17/07/2012 09:21 AM, Warp wrote:
> > Invisible<voi### [at] devnull>  wrote:
> >> And yet, this seems to be how people almost always try to use regexes...
> >
> >    No, it isn't.

> That would explain why the question "how do I parse XHTML with a regex?" 
> is so common on Stack Overflow that a guy actually lost his mind trying 
> to answer it.

It seems to me that we have a different understanding of the expression
"almost always".

To me it means, well, almost always. To you it seems to mean "a couple of
times".

-- 
                                                          - Warp


Post a reply to this message

From: Invisible
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 05:47:40
Message: <500534bc$1@news.povray.org>
On 17/07/2012 10:40 AM, Warp wrote:
> Invisible<voi### [at] devnull>  wrote:
>> 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
>
> You don't seem to grasp what "the most common usage" means. It does not
> mean "the most prominent examples displayed on webpages" or "the most
> prominent examples that I have seen". It means the forms that people
> *most commonly* use, as in raw numbers. Count how many people use a
> completely syntax-less regex or with just a simple wildcard, vs. the
> times when someone has to write a really large and complex expression.
> I'd estimate that the former wins about a million to one.

Well, you can say "I estimate that it's X", and I can say "well I 
estimate that it's Y", and without some actual facts to back any of this 
up, it's a bit of an empty discussion.

Also, if the most common search terms really are just literal strings, 
that doesn't really prove that regexes are a valuable search tool. It 
proves that /literal strings/ are a valuable search tool, no?

>> Or how about
>
>>     dmesg | egrep '(s|h)d[a-z]'
>
> If you want to build your straw man, at least use examples that conform
> to your straw man. That's a bad example because it can be understood in
> about 2 seconds.

OK, so what does it do?

Clearly it runs dmesg and searches the output for some search term. But 
what is the search term?

>> 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";
>>           }
>>         }
>>       }
>>     }
>
> Also, if you are building your straw man, at least try to use actual
> regexes and not some unrelated scripting language.

Come on, regexes are the number one use-case for the entire Perl 
programming language.

Exhibit A: "Perl" stands for "Practical Extraction and Reporting 
Language". Regexes are how Perl does that.

Exhibit B: http://xkcd.com/208/

Perl and regexes are practically synonymous. (Even if /technically/ 
they're not all that closely related.)


Post a reply to this message

From: Warp
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 06:03:49
Message: <50053884@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> Well, you can say "I estimate that it's X", and I can say "well I 
> estimate that it's Y", and without some actual facts to back any of this 
> up, it's a bit of an empty discussion.

The difference is that I have actual extensive personal experience using
systems where regexes are very commonly used, and with people who use them.

Now, granted, I really don't know if you are really a unix guru who has
been using unixes all of his life, but I have got the impression that
you aren't.

> Also, if the most common search terms really are just literal strings, 
> that doesn't really prove that regexes are a valuable search tool. It 
> proves that /literal strings/ are a valuable search tool, no?

Please read again my original reply. The beauty of regexes is that if you
want to just search for a literal string, you usually need no ancillary
syntax at all, and if you need a simple wildcard or other simple pattern,
the search string still remains short and simple. And these two are by
far the most common usages for regexes.

A search (or other pattern matching) system that *only* supported literal
strings and nothing else would be significantly less useful.

> >> Or how about
> >
> >>     dmesg | egrep '(s|h)d[a-z]'
> >
> > If you want to build your straw man, at least use examples that conform
> > to your straw man. That's a bad example because it can be understood in
> > about 2 seconds.

> OK, so what does it do?

I can't believe that you are arguing that a regex is complicated because
you have never used regexes and don't understand their syntax.

Imagine this:

A: "Haskell sucks. It's really hard to understand!"
B: "How much Haskell have you ever written?"
A: "I once tried to write one small program but couldn't figure it out."
B: "Right."

Don't complain about the complexity of a syntax if you haven't even
learned the syntax.

> Come on, regexes are the number one use-case for the entire Perl 
> programming language.

If you want to complain about perl, then complain about perl.

-- 
                                                          - Warp


Post a reply to this message

From: Tim Cook
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 06:10:39
Message: <50053a1f$1@news.povray.org>
On 2012-07-17 04:47, Invisible wrote:
>>> dmesg | egrep '(s|h)d[a-z]'
>>
>> If you want to build your straw man, at least use examples that conform
>> to your straw man. That's a bad example because it can be understood in
>> about 2 seconds.
>
> OK, so what does it do?
>
> Clearly it runs dmesg and searches the output for some search term. But
> what is the search term?

*I'LL* handle this one!  Wa ha.

It's looking for one of the following:
ada adb adc ... adx ady adz
hda hdb hdc ... hdx hdy hdz

...I think.

--
Tim Cook
http://empyrean.sjcook.com


Post a reply to this message

From: Francois Labreque
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 10:21:33
Message: <500574ed$1@news.povray.org>

> On 2012-07-17 04:47, Invisible wrote:
>>>> dmesg | egrep '(s|h)d[a-z]'
>>>
>>> If you want to build your straw man, at least use examples that conform
>>> to your straw man. That's a bad example because it can be understood in
>>> about 2 seconds.
>>
>> OK, so what does it do?
>>
>> Clearly it runs dmesg and searches the output for some search term. But
>> what is the search term?
>
> *I'LL* handle this one! Wa ha.
>
> It's looking for one of the following:
> ada adb adc ... adx ady adz
> hda hdb hdc ... hdx hdy hdz
>
> ...I think.

Yep, but you have a typo in your answer.

Basically, it parses the output of the dmesg command looking for lines 
that talk about hard disks (hda-hdz for IDE/SATA and sda-sdz for SCSI)

-- 
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/*    flabreque    */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/*        @        */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/*   gmail.com     */}camera{orthographic location<6,1.25,-6>look_at a }


Post a reply to this message

From: clipka
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 10:26:57
Message: <50057631$1@news.povray.org>
Am 17.07.2012 12:10, schrieb Tim Cook:
> On 2012-07-17 04:47, Invisible wrote:
>>>> dmesg | egrep '(s|h)d[a-z]'
>>>
>>> If you want to build your straw man, at least use examples that conform
>>> to your straw man. That's a bad example because it can be understood in
>>> about 2 seconds.
>>
>> OK, so what does it do?
>>
>> Clearly it runs dmesg and searches the output for some search term. But
>> what is the search term?
>
> *I'LL* handle this one!  Wa ha.
>
> It's looking for one of the following:
> ada adb adc ... adx ady adz
> hda hdb hdc ... hdx hdy hdz
>
> ...I think.

No.

sda sdb sdc ... sdx sdy sdz
hda hdb hdc ... hdx hdy hdz


Post a reply to this message

From: Tim Cook
Subject: Re: Other people dislike regexes too
Date: 17 Jul 2012 19:43:21
Message: <5005f899$1@news.povray.org>
On 2012-07-17 09:22, Francois Labreque wrote:
> Yep, but you have a typo in your answer.

'a', 's'...the keys are like right next to each other!  Also I was tired.

...yeah, I'll go with that.

<_<

--
Tim Cook
http://empyrean.sjcook.com


Post a reply to this message

From: Invisible
Subject: Re: Other people dislike regexes too
Date: 19 Jul 2012 06:53:34
Message: <5007e72e$1@news.povray.org>
>>>>      dmesg | egrep '(s|h)d[a-z]'
>>>
>>> If you want to build your straw man, at least use examples that conform
>>> to your straw man. That's a bad example because it can be understood in
>>> about 2 seconds.
>
>> OK, so what does it do?
>
> I can't believe that you are arguing that a regex is complicated because
> you have never used regexes and don't understand their syntax.
>
> Imagine this:
>
> A: "Haskell sucks. It's really hard to understand!"
> B: "How much Haskell have you ever written?"
> A: "I once tried to write one small program but couldn't figure it out."
> B: "Right."
>
> Don't complain about the complexity of a syntax if you haven't even
> learned the syntax.

Imagine if instead, somebody had written

   oneOf "sh"
   char 'd'
   letter

You don't even need to know which parsing library or what programming 
language this is to figure out that it matches three characters. (Or 
maybe do you. It's perhaps not /completely/ obvious what the final line 
does.) There's barely anything to learn.

It's a lot more typing, of course. But personally, that doesn't bother me.

>> Come on, regexes are the number one use-case for the entire Perl
>> programming language.
>
> If you want to complain about perl, then complain about perl.

Have I ever mentioned that I also really hate Perl?

Of course, the only reason that anybody ever uses Perl is because it has 
built-in regex support. This, together with low-level text munging, is 
literally ALL PERL DOES! >_<


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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