About Regular Expressions

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-expressions.info/ 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 :wink: (Just like some of mine do, I have to admit :wink:

···

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

--
Brian Schröder
http://ruby.brian-schroeder.de/

"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?RegexpCookbook ?

Kind regards

    robert

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.

···

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.

I don't think there needs to be a FAQ or anything like that as much as there needs to be a single site that's a good repository of pointers to information. When I have a question about Ruby, I'll check the ML archives through Google, or ruby-doc if it seems like the sort of thing likely to be in the RDoc.

I was probably the last person to "cry wolf", so to speak, but seeing as my problem was a Regexp problem, I didn't have much hope with Google, because doing text searches for regexp characters doesn't work often, nor with RDoc, because RDoc is too granular to have that sort of information.

Personally I don't need a regexp FAQ or tutorial, I need a bits-and-pieces reference, and I would've found that either in:

1. An online reference page like Regular Expressions Reference (thanks for the pointer, Brian!)

2. The Pickaxe v2, either on p. 71 or on p. 325.

Obviously, it didn't occur to me to look in either place this last time around; I'll try to remember that for next time. But if we want people to do more looking on their own, I think it needs to be easier to do that. I have some guesses as to what could change, but I personally don't have any time to do anything about it so I'm not inclined to complain about it.

F.

···

On Nov 18, 2004, at 5: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.

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.

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'.

* 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-expressions.info/ 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 :wink: (Just like some of
mine do, I have to admit :wink:

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

* 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?RegexpCookbook ?

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

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

···

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.

--
http://blog.casey-sweat.us/

* 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);}

* Francis Hwang <sera@fhwang.net> [Nov 18, 2004 15:50]:

> 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.

Personally I don't need a regexp FAQ or tutorial, I need a
bits-and-pieces reference, and I would've found that either in:

1. An online reference page like
Regular Expressions Reference (thanks for the
pointer, Brian!)

2. The Pickaxe v2, either on p. 71 or on p. 325.

Obviously, it didn't occur to me to look in either place this last time
around; I'll try to remember that for next time. But if we want people
to do more looking on their own, I think it needs to be easier to do
that.

Precisely my point.

I have some guesses as to what could change, but I personally don't
have any time to do anything about it so I'm not inclined to complain
about it.

:-), perhaps I should have kept my mouth shut as well, as I don't have
time to spare at the moment.
  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" <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 Captcha ?

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/index.html

Kind regards

    robert

* Jason Sweat <jason.sweat@gmail.com> [Nov 18, 2004 15: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.

> 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?

This is the right forum, I didn't argue with that.

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).

I seem to need a couple of lessons on interacting with other humans...

Your case is typical of the problems I felt I had seen coming up on this
list these past few weeks. What I sought was a solution to this problem
(not the questions as such, but the fact that they were asked in the
first place). It seems that this wasn't made clear enough in my
posting. As I've stated in other replies, I think that here is a need
for better and more accessible documentation for using regular
expressions, as many seem to have problems writing and using them.
  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);}

As the person who posted that question, let me just say that while there are lots of Ruby details I forget, you couldn't reasonably call me a newbie. One reason, I think, is that the char class I was dealing with had other characters that distracted me:

/^[0123456789.-*]+/

... which isn't certainly a sign of programming genius, but I like to think is the sort of odd blind spot that happens to most programmers from time to time. I'd also like to think that most of what I post here isn't nearly that newbie-ish, but then I'm obviously not the best judge of that.

F.

···

On Nov 18, 2004, at 9:26 AM, Nikolai Weibull wrote:

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.

> This is terrible.

Thanks.

Nikolai the Terrible ...

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

The problem I was aiming to remedy.

... -ly Good :wink:

> 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?

oops. yes.

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.

Indeed, I do always try to remember to taste my own medicines first. Thanks
for the reminder!

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.

Grace be upon you. It seems so few people are willing to apologize for
anything these days. Thank you. I think the problem was that you weren't very
specific about which posts you were referring and then on top of it came
across a bit harsh.

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...

I don;t think so. You may well have a point. So I welcome the outspoken
concerns.

My opinion is this: Regexp's are for CS-heads --those who really love
programming for its it's own sake. Regexp are about as terse and cryptic as
one can get, and thus have a steep learning curve. Indeed, I have read a good
bit of docs on them and I still have troubles. Rather than write more
documentation, I think it would be the bomb if someone would invent the "Next
Big Thing"(TM) in string pattern matching. But of course, that's a much
taller order.

T.

P.S. Perl 6 regular expressions look to be a move in the right direction
though. Has anyone checked that out recently?

···

On Thursday 18 November 2004 09:26 am, Nikolai Weibull wrote:

* 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?RegexpCookbook ?
>
> 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/index.html

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

* Francis Hwang <sera@fhwang.net> [Nov 18, 2004 15:50]:

>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.

As the person who posted that question, let me just say that while
there are lots of Ruby details I forget, you couldn't reasonably call
me a newbie.

And that's why I didn't do that. I said that the question in question
(hoho) was a newbyish in nature. I didn't pass any judgement about your
abilities as a programmer.

One reason, I think, is that the char class I was dealing with had
other characters that distracted me:

/^[0123456789.-*]+/

... which isn't certainly a sign of programming genius, but I like to
think is the sort of odd blind spot that happens to most programmers
from time to time. I'd also like to think that most of what I post
here isn't nearly that newbie-ish, but then I'm obviously not the best
judge of that.

I don't keep tabs on what people usually post, so I can't comment on
that.

Anyway, do you, as the asker of the question that triggered my posting,
feel that using regular expressions is difficult and, if so, that there
could be better documentation, especially for Ruby?
  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);}

My experience has been the opposite.

At my wife's company, they spend a significant portion of everyday importing raw text reports from their database into Excel for various uses. Some of the reports do not go into Excel well at all. A large chunk of most employee's day is spent cleaning up these reports, by hand. (I'm considering one of these reports for a future Ruby Quiz, if that gives you any idea how wonky they can be.)

When my wife came to me for help and showed me the problem, the solution turned out to be simple. I helped her download a simple text editor with Regular Expression search and replace, over the phone. That evening, I taught her a useful subset of Regular Expression and together we built and printed a "cheat sheet" she could take to work with her.

My wife is no programmer. She's a slightly above average computer user. She's great with Excel and can record macros, but she would never thing of editing one, by way of example. It literally took me about three hours to get her doing useful things with Regular Expression. Today, she's the wizard at her company they all come to for help. She's easily the most productive employee they have, when it comes to any kind of reporting work.

I'm not trying to imply anything about you or your beliefs. I'm just saying that some people don't seem to have too much trouble with them. I know my wife still keeps that cheat sheet right next to her computer. Perhaps a trick like that would be of some use to you or other folks who struggle with Regular Expression.

James Edward Gray II

···

On Nov 18, 2004, at 9:44 AM, trans. (T. Onoma) wrote:

My opinion is this: Regexp's are for CS-heads --those who really love
programming for its it's own sake. Regexp are about as terse and cryptic as
one can get, and thus have a steep learning curve.

* trans. (T. Onoma) <transami@runbox.com> [Nov 18, 2004 16:50]:

> > This is terrible.

> Thanks.

Nikolai the Terrible ...

Weird, my middle name is Iwan. Except for the spelling, it all seems to
fit ;-).

> 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.

Grace be upon you. It seems so few people are willing to apologize for
anything these days. Thank you. I think the problem was that you
weren't very specific about which posts you were referring and then on
top of it came across a bit harsh.

Yeah, I realize that now...I always manage to do that for some reason.
It's not very nice to sound angry.

> 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...

I don;t think so. You may well have a point. So I welcome the
outspoken concerns.

My opinion is this: Regexp's are for CS-heads --those who really love
programming for its it's own sake. Regexp are about as terse and
cryptic as one can get, and thus have a steep learning curve.

Yeah, that's perhaps the biggest problem. It's fine when you're working
with them interactively (well, I don't think so personally, but that is
one reason as to why they are terse to begin with (+ mathematics)), but
when writing them in a program, I think you should be presented with a
somewhat more understandable syntax. That's what I'm working on with my
masters' thesis actually (but from the interactive side actually).

Indeed, I have read a good bit of docs on them and I still have
troubles. Rather than write more documentation, I think it would be
the bomb if someone would invent the "Next Big Thing"(TM) in string
pattern matching. But of course, that's a much taller order.

Yes. It would be a welcome change though. Perhaps proving P = NP
and/or English/Swedish/Japanese/Whatever = Context-Free would make
things more interesting :wink:

P.S. Perl 6 regular expressions look to be a move in the right
direction though. Has anyone checked that out recently?

Yes, it is a welcome change. It promotes abstraction of regular
expressions as rules and sets of rules, called grammars. Most of the
metacharacters are retained, but the end result is a much cleaner
language to work with (and a much cleaner implementation as well it
seems). I still think they've gone a bit overboard, but they have good
reason.

Enjoy,
  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);}

I hope that this does not shun anyone away from posting. It must be allowed to post a "dumb" questions from time to time as Nikolai himself said, he who is not interested in answering "dumb" questions just skips them.

Doing a bit of research on your own is the politeness I expect everyone to have done. As I said before, I think that every mere mortal has some blind spots sometimes. And Francis question was also answered as expected with a correction and a pointer for further reading. I'm shure every poster that gets this kind of treatment will learn something new.

Maybe we should strip the harsh tone from Nikolais post and consider if it is a sensible idea to put up more documentation, or a link to some good existing documentation on ruby-doc or "ri Regexp"

Regards,

Brian

···

On Thu, 18 Nov 2004 23:43:33 +0900 Francis Hwang <sera@fhwang.net> wrote:

On Nov 18, 2004, at 9:26 AM, Nikolai Weibull wrote:
> [post]
As the person who posted that question, let me just say that while
there are lots of Ruby details I forget, you couldn't reasonably call
me a newbie. One reason, I think, is that the char class I was dealing
with had other characters that distracted me:

/^[0123456789.-*]+/

... which isn't certainly a sign of programming genius, but I like to
think is the sort of odd blind spot that happens to most programmers
from time to time. I'd also like to think that most of what I post here
isn't nearly that newbie-ish, but then I'm obviously not the best judge
of that.

F.

--
Brian Schröder
http://www.brian-schroeder.de/