http://qs321.pair.com?node_id=923913

I did a small offering to my co-workers on regular expressions. The approach I decided to take:

Emphasize the gentle learning curve of regular expressions. (Whut.) In other words, if you know them a little, you can use them a little. Let the anchors be their anchor: ^ and $, then build from there. The next logical steps are: .+ and .* homegrown character classes built-in character classes (\w and the like)

I moved quickly to using backreferences to replace strings, since we often have to generate scripts from lists that the users send us.

Try to find things they are actually doing and show how regexps can replace "elaborate string manipulation using only built-in string functions." Remind them that less code means fewer bugs. Enlist the help of someone who works on another team and see what they do that can be made easier with regular expressions. (If that team is a large team, so much the better.) If your audience sees that you've taken the trouble to tailor your presentation to their everyday needs, they will respond.

I'd also keep it short. The goal won't be to teach them the ins and outs of regexps, just to let them see how they can be of value

Replies are listed 'Best First'.
Re^2: regexp class
by JavaFan (Canon) on Sep 02, 2011 at 21:25 UTC
    Remind them that less code means fewer bugs.
    I'm very suspicious of this. The logical extreme of this is that golfed code contains the fewest bugs.

    I think that "less code means less bugs" is a nice catchphrase, but that noone has actually proven this.

    Now, if you would have said "less functionality means less bugs", I'd be more inclined to agree with you.

      The logical extreme of this is that golfed code contains the fewest bugs.

      You missed the ultimate silly extreme. No code means no bugs. Try and disprove that :)

      Taking good ideas to silly extremes does not disprove them as good ideas.

      For a huge proportion of the population -- of almost anywhere -- eating less is a good idea. That starving yourself causes death does not disprove that.

      I think that "less code means less bugs" is a nice catchphrase, but that noone has actually proven this.

      Actually, they have. Over and over.

      When FORTRAN and COBOL took over from assembler, it was clearly demonstrated that more code was written more quickly with considerably less bugs.

      And given equivalent skills and testing regimes, coding in Perl will result in less bugs than writing in C.

      And if the anecdotal evidence isn't self-evident enough for you, I'll try and dig up references to some of the research I was party to back in the '80s. Though I'm not sure I'll be able to access it.

      In the mean time, try looking in the Haskell world. It's one of their mantras and they usually back their stuff up with research.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        You missed the ultimate silly extreme. No code means no bugs. Try and disprove that
        That's trivial to disprove. Most code is intended to do something. If it doesn't do what is intended to be done, it isn't correct. No code means nothing is done.
Re^2: regexp class
by armstd (Friar) on Sep 06, 2011 at 18:05 UTC

    So.. you left out a critical piece of information here.

    How did it go? :-)

    --Dave