# About Regular Expressions

**URL:** <https://rubytalk.org/t/about-regular-expressions/14865>\
**Category:** ruby-talk\
**Created:** [18 November 2004 10:34 UTC](https://rubytalk.org/t/about-regular-expressions/14865 "2004-11-18T10:34:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 10:34 UTC](https://rubytalk.org/t/about-regular-expressions/14865/1 "2004-11-18T10:34:54Z")

</div>

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?  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Brian\_SchrA\_der](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@Brian\_SchrA\_der](https://rubytalk.org/u/Brian_SchrA_der)\
**Post date:** [18 November 2004 12:11 UTC](https://rubytalk.org/t/about-regular-expressions/14865/2 "2004-11-18T12:11:00Z")

</div>

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/](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 😉 (Just like some of mine do, I have to admit 😉

> **···**
>
> 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?  
> > &nbsp;&nbsp;nikolai
> > 
> > --  
> > ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::  
> > ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::  
> > ::: page: [www.pcppopper.org](http://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/](http://ruby.brian-schroeder.de/)

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [18 November 2004 12:13 UTC](https://rubytalk.org/t/about-regular-expressions/14865/3 "2004-11-18T12:13:16Z")

</div>

"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](http://www.rubygarden.org/ruby?RegexpCookbook) ?

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![T\_Onoma](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@T\_Onoma](https://rubytalk.org/u/T_Onoma)\
**Post date:** [18 November 2004 13:04 UTC](https://rubytalk.org/t/about-regular-expressions/14865/4 "2004-11-18T13:04:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Francis\_Hwang1](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Francis\_Hwang1](https://rubytalk.org/u/Francis_Hwang1)\
**Post date:** [18 November 2004 14:39 UTC](https://rubytalk.org/t/about-regular-expressions/14865/5 "2004-11-18T14:39:47Z")

</div>

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](http://www.regular-expressions.info/reference.html) (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.

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://rubytalk.org/u/gabriele_renzi)\
**Post date:** [18 November 2004 12:33 UTC](https://rubytalk.org/t/about-regular-expressions/14865/6 "2004-11-18T12:33:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 12:49 UTC](https://rubytalk.org/t/about-regular-expressions/14865/7 "2004-11-18T12:49:11Z")

</div>

\* 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/](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 😉 (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.  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 12:52 UTC](https://rubytalk.org/t/about-regular-expressions/14865/8 "2004-11-18T12:52:21Z")

</div>

\* 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](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.  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Jason\_Sweat](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@Jason\_Sweat](https://rubytalk.org/u/Jason_Sweat)\
**Post date:** [18 November 2004 14:13 UTC](https://rubytalk.org/t/about-regular-expressions/14865/9 "2004-11-18T14:13:26Z")

</div>

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/](http://blog.casey-sweat.us/)

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 14:26 UTC](https://rubytalk.org/t/about-regular-expressions/14865/10 "2004-11-18T14:26:01Z")

</div>

\* 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...  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 15:07 UTC](https://rubytalk.org/t/about-regular-expressions/14865/11 "2004-11-18T15:07:54Z")

</div>

\* 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](http://www.regular-expressions.info/reference.html) (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.  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [18 November 2004 13:03 UTC](https://rubytalk.org/t/about-regular-expressions/14865/12 "2004-11-18T13:03:17Z")

</div>

"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](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

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](http://www.oreilly.com/catalog/regex/index.html)

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 14:33 UTC](https://rubytalk.org/t/about-regular-expressions/14865/13 "2004-11-18T14:33:03Z")

</div>

\* 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.  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Francis\_Hwang1](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Francis\_Hwang1](https://rubytalk.org/u/Francis_Hwang1)\
**Post date:** [18 November 2004 14:43 UTC](https://rubytalk.org/t/about-regular-expressions/14865/14 "2004-11-18T14:43:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![T\_Onoma](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@T\_Onoma](https://rubytalk.org/u/T_Onoma)\
**Post date:** [18 November 2004 15:44 UTC](https://rubytalk.org/t/about-regular-expressions/14865/15 "2004-11-18T15:44:03Z")

</div>

> \> 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 😉

> \> 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:

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 14:04 UTC](https://rubytalk.org/t/about-regular-expressions/14865/16 "2004-11-18T14:04:46Z")

</div>

\* 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](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](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.  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 15:05 UTC](https://rubytalk.org/t/about-regular-expressions/14865/17 "2004-11-18T15:05:18Z")

</div>

\* 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?  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [18 November 2004 18:36 UTC](https://rubytalk.org/t/about-regular-expressions/14865/18 "2004-11-18T18:36:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [18 November 2004 19:10 UTC](https://rubytalk.org/t/about-regular-expressions/14865/19 "2004-11-18T19:10:48Z")

</div>

\* 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 😉

> 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,  
&nbsp;&nbsp;nikolai

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

---

<div class="post-metadata">

**Author:** ![Brian\_SchrA\_der](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@Brian\_SchrA\_der](https://rubytalk.org/u/Brian_SchrA_der)\
**Post date:** [18 November 2004 21:09 UTC](https://rubytalk.org/t/about-regular-expressions/14865/20 "2004-11-18T21:09:59Z")

</div>

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/](http://www.brian-schroeder.de/)

[Next page](https://rubytalk.org/t/about-regular-expressions/14865.md?page=2)
