[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

About Regular Expressions

Nikolai Weibull

11/18/2004 10:35:00 AM

Lately there have been a bunch of posts on this list about regular
expressions in Ruby and people seem to cry wolf whenever they don't get
them quite right. By crying wolf here I mean that they suspect a bug.
That's most often the same as blaming core-dumps on the operating
system. It's time that people try to reason about what they've actually
written and look at the documentation (which may be too limited?) before
complaining here.

I am not suggesting that these question stop entirely, but I request
that they be well thought out before. Still, there seems to be a need
for a FAQ or similar, covering regular expression basics and common
pitfalls - perhaps even including common idioms and uses in Ruby.

I don't have time for this myself at the moment, so is anyone else up
for the task?
nikolai


--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


30 Answers

Robert Klemme

11/18/2004 12:08:00 PM

0


"Nikolai Weibull" <mailing-lists.ruby-talk@rawuncut.elitemail.org> schrieb
im Newsbeitrag news:20041118103443.GA9088@puritan.pcp.ath.cx...
> Lately there have been a bunch of posts on this list about regular
> expressions in Ruby and people seem to cry wolf whenever they don't get
> them quite right. By crying wolf here I mean that they suspect a bug.
> That's most often the same as blaming core-dumps on the operating
> system. It's time that people try to reason about what they've actually
> written and look at the documentation (which may be too limited?) before
> complaining here.

In principle this applies for all kind of questions and complaints. Maybe
it's just a sign that regular expressions are not easy to grasp for people
without CS background.

> I am not suggesting that these question stop entirely, but I request
> that they be well thought out before. Still, there seems to be a need
> for a FAQ or similar, covering regular expression basics and common
> pitfalls - perhaps even including common idioms and uses in Ruby.
>
> I don't have time for this myself at the moment, so is anyone else up
> for the task?
> nikolai

Like http://www.rubygarden.org/ruby?Rege... ?

Kind regards

robert

Brian Schröder

11/18/2004 12:11:00 PM

0

On Thu, 18 Nov 2004 19:34:54 +0900
Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

> Lately there have been a bunch of posts on this list about regular
> expressions in Ruby and people seem to cry wolf whenever they don't get
> them quite right. By crying wolf here I mean that they suspect a bug.
> That's most often the same as blaming core-dumps on the operating
> system. It's time that people try to reason about what they've actually
> written and look at the documentation (which may be too limited?) before
> complaining here.
>
> I am not suggesting that these question stop entirely, but I request
> that they be well thought out before. Still, there seems to be a need
> for a FAQ or similar, covering regular expression basics and common
> pitfalls - perhaps even including common idioms and uses in Ruby.
>
> I don't have time for this myself at the moment, so is anyone else up
> for the task?
> nikolai
>
>
> --
> ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
> ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
> ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
> main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
>

There are lots of regexp tutorials on the web. To me it does not seem reasonable to duplicate this effort. Just do a quick google for regular expression and you get a dozen hits.

http://www.regular-express... is a good introductory text. The only thing missing on this site is a reference to ruby. Maybe if enough people bug him about it, he will include it ;). I already asked him to include ruby in the list of languages that support regexps.

It is true that sometimes people are too easily blame the bugs onto others, but what I like here in this newsgroup, is that even if your asking a dumb question you normally get a helpfull pointer a polite tone.

In fact you are also giving constructive critic here, but as I read the first part of your eMail I felt it a little rough. Requesting that people try to think is correct, but one should also accept that sometimes there exist weird knots in the head that can more easily be cut together with other people than alone.

best regards,

Brian


PS: Your homepage is broken. (And it uses php ;) (Just like some of mine do, I have to admit ;)

--
Brian Schröder
http://ruby.brian-sch...



gabriele renzi

11/18/2004 12:30:00 PM

0

Robert Klemme ha scritto:

> In principle this applies for all kind of questions and complaints. Maybe
> it's just a sign that regular expressions are not easy to grasp for people
> without CS background.
>
>

I guess that for what relates to regex there is also the 'there is a new
engine somewhere, maybe it's broken'.

Nikolai Weibull

11/18/2004 12:49:00 PM

0

* Brian Schröder <ruby@brian-schroeder.de> [Nov 18, 2004 13:20]:
> > I am not suggesting that these question stop entirely, but I request
> > that they be well thought out before. Still, there seems to be a need
> > for a FAQ or similar, covering regular expression basics and common
> > pitfalls - perhaps even including common idioms and uses in Ruby.

> There are lots of regexp tutorials on the web. To me it does not seem
> reasonable to duplicate this effort. Just do a quick google for
> regular expression and you get a dozen hits.

Yet people direct their questions to this mailing-list.

> http://www.regular-express... is a good introductory text. The
> only thing missing on this site is a reference to ruby. Maybe if
> enough people bug him about it, he will include it ;). I already asked
> him to include ruby in the list of languages that support regexps.

I'd say its so-so at best. Still, I know that there are a lot of
resources, but no one seems to find them (or try to for that matter).
Perhaps I should have mentioned that the idea was that something was
going to go to ruby-doc.org for easy reference.

> PS: Your homepage is broken. (And it uses php ;) (Just like some of
> mine do, I have to admit ;)

Yeah, the providers kind of messed up royally. I haven't had time to
fix it, nor move to Rails or something similar. In any case, the
database was lost in a hard drive failure on the provider's server,
which would make the page very boring even if it was working.
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


Nikolai Weibull

11/18/2004 12:52:00 PM

0

* Robert Klemme <bob.news@gmx.net> [Nov 18, 2004 13:20]:
> > Lately there have been a bunch of posts on this list about regular
> > expressions in Ruby and people seem to cry wolf whenever they don't
> > get them quite right. By crying wolf here I mean that they suspect
> > a bug. That's most often the same as blaming core-dumps on the
> > operating system. It's time that people try to reason about what
> > they've actually written and look at the documentation (which may be
> > too limited?) before complaining here.

> In principle this applies for all kind of questions and complaints. Maybe
> it's just a sign that regular expressions are not easy to grasp for people
> without CS background.

Perhaps, but it's sad that no one can for their life consider the fact
that maybe they've done something wrong themselves, not the writers of
the software/programming language they are using.

> > I am not suggesting that these question stop entirely, but I request
> > that they be well thought out before. Still, there seems to be a
> > need for a FAQ or similar, covering regular expression basics and
> > common pitfalls - perhaps even including common idioms and uses in
> > Ruby.

> Like http://www.rubygarden.org/ruby?Rege... ?

Hardly. That page is for writing regular expressions that match some
specific data, not a discussion about how to write and use regular
expressions in the large. Still, a wiki page would work fine.
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


Robert Klemme

11/18/2004 1:02:00 PM

0


"Nikolai Weibull" <mailing-lists.ruby-talk@rawuncut.elitemail.org> schrieb
im Newsbeitrag news:20041118125218.GF9088@puritan.pcp.ath.cx...
> * Robert Klemme <bob.news@gmx.net> [Nov 18, 2004 13:20]:
> > > Lately there have been a bunch of posts on this list about regular
> > > expressions in Ruby and people seem to cry wolf whenever they don't
> > > get them quite right. By crying wolf here I mean that they suspect
> > > a bug. That's most often the same as blaming core-dumps on the
> > > operating system. It's time that people try to reason about what
> > > they've actually written and look at the documentation (which may be
> > > too limited?) before complaining here.
>
> > In principle this applies for all kind of questions and complaints.
Maybe
> > it's just a sign that regular expressions are not easy to grasp for
people
> > without CS background.
>
> Perhaps, but it's sad that no one can for their life consider the fact
> that maybe they've done something wrong themselves, not the writers of
> the software/programming language they are using.

Well, yes, but it's not true that "no one" considers the option of his own
failure. That's dramatically exaggerated IMHO, although I readily concede
that it's a general human tendency.

> > > I am not suggesting that these question stop entirely, but I request
> > > that they be well thought out before. Still, there seems to be a
> > > need for a FAQ or similar, covering regular expression basics and
> > > common pitfalls - perhaps even including common idioms and uses in
> > > Ruby.
>
> > Like http://www.rubygarden.org/ruby?Rege... ?
>
> Hardly. That page is for writing regular expressions that match some
> specific data, not a discussion about how to write and use regular
> expressions in the large. Still, a wiki page would work fine.
> nikolai

In *that* case a book like "Mastering Regular Expressions" might be far
more appropriate as the matter is quite complex. See here for example:
http://www.oreilly.com/catalog/regex/...

Kind regards

robert

T. Onoma

11/18/2004 1:05:00 PM

0

On Thursday 18 November 2004 05:34 am, Nikolai Weibull wrote:
| Lately there have been a bunch of posts on this list about regular
| expressions in Ruby and people seem to cry wolf whenever they don't get
| them quite right. By crying wolf here I mean that they suspect a bug.
| That's most often the same as blaming core-dumps on the operating
| system. It's time that people try to reason about what they've actually
| written and look at the documentation (which may be too limited?) before
| complaining here.

This is terrible. Not only is it unfair to disenfranchise newbies who, for
obvious reasons, would struggle with regular expressions, but the whole
premise if false. (ASFICT) I am responsible for most if not all the latest
R.E. posts. And I do not recall once suspecting a bug. I have asked about
extending features (such as Regexp.arity) and whether certain existing
features might not be more useful if they worked differently (like #scan).
Never did I cry wolf. (For a taste of your own medicine) Perhaps it's time
for you to try to read more carefully.

T.


Nikolai Weibull

11/18/2004 2:05:00 PM

0

* Robert Klemme <bob.news@gmx.net> [Nov 18, 2004 14:10]:
> > > In principle this applies for all kind of questions and
> > > complaints. Maybe it's just a sign that regular expressions are
> > > not easy to grasp for people without CS background.

> > Perhaps, but it's sad that no one can for their life consider the fact
> > that maybe they've done something wrong themselves, not the writers of
> > the software/programming language they are using.

> Well, yes, but it's not true that "no one" considers the option of his own
> failure. That's dramatically exaggerated IMHO, although I readily concede
> that it's a general human tendency.

Sure, it's an exaggeration, but as a teacher's assistant at school I've
come to realize that CS students are exceedingly lazy and prone to blame
others for their own mistakes.

Listen, I'm not saying that people act in this manner all the time, but
I noticed that there have been quite a few posts of this kind and I
figured that this was a result of some lack of proper documentation or
some such. I'm not here to place blame, nor to bitch about people
asking "stupid" questions (I simply delete and ignore those threads if I
don't feel like answering them). My goal was to solve the problem once
and for all instead of someone having to do it once a week when one of
these questions comes up on the list.

> > > > I am not suggesting that these question stop entirely, but I
> > > > request that they be well thought out before. Still, there
> > > > seems to be a need for a FAQ or similar, covering regular
> > > > expression basics and common pitfalls - perhaps even including
> > > > common idioms and uses in Ruby.
> >
> > > Like http://www.rubygarden.org/ruby?Rege... ?
> >
> > Hardly. That page is for writing regular expressions that match
> > some specific data, not a discussion about how to write and use
> > regular expressions in the large. Still, a wiki page would work
> > fine.

> In *that* case a book like "Mastering Regular Expressions" might be far
> more appropriate as the matter is quite complex. See here for example:
> http://www.oreilly.com/catalog/regex/...

Yes, it's a good book, but it's short on Ruby specifics and not everyone
wants to buy a book to use regular expressions properly. Thus, some
kind of _good_ introduction to regular expressions and their use in Ruby
is still desirable.
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


Jason Sweat

11/18/2004 2:13:00 PM

0

On Thu, 18 Nov 2004 22:04:43 +0900, trans. (T. Onoma)
<transami@runbox.com> wrote:
> On Thursday 18 November 2004 05:34 am, Nikolai Weibull wrote:
> | Lately there have been a bunch of posts on this list about regular
> | expressions in Ruby and people seem to cry wolf whenever they don't get
> | them quite right. By crying wolf here I mean that they suspect a bug.
> | That's most often the same as blaming core-dumps on the operating
> | system. It's time that people try to reason about what they've actually
> | written and look at the documentation (which may be too limited?) before
> | complaining here.
>
> This is terrible. Not only is it unfair to disenfranchise newbies who, for
> obvious reasons, would struggle with regular expressions, but the whole
> premise if false. (ASFICT) I am responsible for most if not all the latest
> R.E. posts. And I do not recall once suspecting a bug. I have asked about
> extending features (such as Regexp.arity) and whether certain existing
> features might not be more useful if they worked differently (like #scan).
> Never did I cry wolf. (For a taste of your own medicine) Perhaps it's time
> for you to try to read more carefully.

I too brought up a regex question recently. My issue was that I
understood how a particular regex worked in other languages (Perl,
PHP), but was unable to implement in Ruby. I was specifically seeking
advice on how to do it "the Ruby way". If this is not the appropriate
forum for that, where else would be?

In most cases like this, it seems to me if you feel the question is
too naive, you are free to ignore the thread, and someone who has more
pity or patience can help the individual who posted. Trying to throw
up barriers to posting questions seems like isolationism that is not
very characteristic of this list (at least from the brief time I have
been lurking here).

YMMV

Regards,
Jason
--
http://blog.casey...


Nikolai Weibull

11/18/2004 2:26:00 PM

0

* trans. (T. Onoma) <transami@runbox.com> [Nov 18, 2004 14:10]:
> > Lately there have been a bunch of posts on this list about regular
> > expressions in Ruby and people seem to cry wolf whenever they don't
> > get them quite right. By crying wolf here I mean that they suspect
> > a bug. That's most often the same as blaming core-dumps on the
> > operating system. It's time that people try to reason about what
> > they've actually written and look at the documentation (which may be
> > too limited?) before complaining here.

> This is terrible.

Thanks.

> Not only is it unfair to disenfranchise newbies who, for obvious
> reasons, would struggle with regular expressions,

The problem I was aiming to remedy.

> but the whole premise if false. (ASFICT) I am responsible for most if
> not all the latest R.E. posts. And I do not recall once suspecting a
> bug.

> I have asked about extending features (such as Regexp.arity) and
> whether certain existing features might not be more useful if they
> worked differently (like #scan). Never did I cry wolf.

ASFICT == AFAICT?

I did not accuse any specific entity of misdoings, nor did I consider
your posts; which are rather old by now. I do not consider a post
discussing the arity of regular expressions equivalent with one that
asks if it is a bug that /[...a-b]/ doesn't match '-'. The first one is
a rather esoteric question, which certainly proved that you weren't a
newbie; the second is rather more newbyish as it shows unfamiliarity
with one of the most basic regular expressions shorthands. My intention
wasn't to dismiss the question as such, but wondering if it was a bug
certainly shows that the person in question hadn't read up on regular
expressions before trying to use them.

The question then is whether the person was just being lazy or hadn't
found proper documentation. My suspicion is that we are dealing with
the second case - which implies that we need better documentation, which
was my original intent and suggestion. If it was the first, then I
don't really have to say much more.

> (For a taste of your own medicine) Perhaps it's time for you to try to
> read more carefully.

And you aswell.

Listen, my intent wasn't to place blame nor accuse any individual of any
wrongdoings. I just wanted to point out that we'd been having a lot of
the same kind of discussions and that they seemed to suggest a very poor
understanding of regular expressions and their use among the Ruby-Newby
populace.

Apparently I managed to press quite a few buttons with my post and if
anyone was offended I apologize. I, however, still think my thesis and
conclusion are valid.

My reasoning was that people either weren't looking at the documentation
or that the documentation was too limited in nature. Robert Klemme
suggested that there was a lot of documentation available (I agree). If
this is true, then why are people still asking very basic questions?
Either they are too lazy to look up the documentation, or they can't
find any. Both are a result of there not being a good resource of
introductory (nor advanced for that matter) material about using regular
expressions, especially for Ruby.

I suggested that this situation be remedied, but that I couldn't do it
myself. The general attitude so far seems to be that I should shut the
fuck up and write it myself if I think this is such a big deal...
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}