Re: Learning regular expressions

2003-03-20 Thread Philip Newton
On 19 Mar 2003 at 19:31, Chris Benson wrote:

[Getting ORA books at a discount as a *.pm member]
 On Wed, Mar 19, 2003 at 07:06:53PM +0100, Philip Newton wrote:
  (Presumably only works when ordering directly from ORA.)
 
 Yup, I used to have a card with Josette's contact details, ... I'll try
 to find it.  Or via UKUUG if you're in that.

Re: UKUUG - not likely, as I'm in Germany :). But if you could dig out 
the card, I'd appreciate it. Maybe they do the same thing at ORA.de.

Cheers,
Philip
-- 
Philip Newton [EMAIL PROTECTED]




Re: Learning regular expressions

2003-03-19 Thread Alex McLintock

 On Tue, Mar 18, 2003 at 12:41:18PM +, Phil Dobbin
([EMAIL PROTECTED]) wrote:
  Hey, I've bought thirty-two O'Reilly books as it is ;-)

From: Dave Cross [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 3:51 PM
 I quick count in the area round my desk at home finds 120 O'Reilly books.
 There are others at work as well I think.



Luis Campos de Carvalho wrote:
  pedanticHey, Dave, do you work at a Book Store? =-]/pedantic


Well my significant other *does* work in a book store - and used to work in 
computing - and I can only see fifteen O'Reilly books in this room, plus 
another five in the hallway, [ plus whatever mstevens or Tantrix have would 
be easily available]

Admittedly ten/twelve of those O'Reilly books are on CD but



Available for java/perl/C++/web development in London, UK or nearby.
Apache FOP, Cocoon, Turbine, Struts,XSL:FO, XML, Tomcat, JSP
http://www.OWAL.co.uk/



Re: Learning regular expressions

2003-03-19 Thread Philip Newton
On 18 Mar 2003 at 14:32, Chris Benson wrote:

[ORA books]
 I blame Josette. You can't turn round without getting a discount: London
 PerlMounger - get a discount, Tyneside PerlMounger - get a discount,
 UKUUG member - get a discount, ...

How does that work? Just mention I'm a Foo.pm member when placing 
your order?

Seems a bit too easy to me.

(Presumably only works when ordering directly from ORA.)

Cheers,
Philip
-- 
Philip Newton [EMAIL PROTECTED]




Re: Learning regular expressions

2003-03-19 Thread Chris Benson
On Wed, Mar 19, 2003 at 07:06:53PM +0100, Philip Newton wrote:
 On 18 Mar 2003 at 14:32, Chris Benson wrote:
 
 [ORA books]
  I blame Josette. You can't turn round without getting a discount: London
  PerlMounger - get a discount, Tyneside PerlMounger - get a discount,
  UKUUG member - get a discount, ...
 
 How does that work? Just mention I'm a Foo.pm member when placing 
 your order?

Yup, they arrive from (whichever publisher Pearson? handles ORA in the
UK) in a few days. 

 Seems a bit too easy to me.

That's the problem :-)
 
 (Presumably only works when ordering directly from ORA.)

Yup, I used to have a card with Josette's contact details, ... I'll try
to find it.  Or via UKUUG if you're in that.
-- 
Chris Benson



RE: Learning regular expressions

2003-03-18 Thread Gareth Kirwan
Hey - I didn't realise there was a second edition.

Mastering Regular expressions is what I learnt from, found it great.

Gareth

 -Original Message-
 [mailto:[EMAIL PROTECTED] Behalf Of Mark Fowler
 
 You'd be better off with the 2nd Edition.
 
 O'Reilly: 0-596-00289-0
 http://www.oreilly.com/catalog/regex2/
 
 Shouldn't someone be reviewing this for the site?
 
 Mark.
 
 -- 
 #!/usr/bin/perl -T
 use strict;
 use warnings;
 print q{Mark Fowler, [EMAIL PROTECTED], 
 http://twoshortplanks.com/};
 






Re: Learning regular expressions

2003-03-18 Thread Mark Fowler
On Mon, 17 Mar 2003, Phil Dobbin wrote:

 You can't go wrong with Jeffrey Friedl's `Mastering Regular Expressions'
 (O'Reilly: 1-56592-257-3).

You'd be better off with the 2nd Edition.

O'Reilly: 0-596-00289-0
http://www.oreilly.com/catalog/regex2/

Shouldn't someone be reviewing this for the site?

Mark.

-- 
#!/usr/bin/perl -T
use strict;
use warnings;
print q{Mark Fowler, [EMAIL PROTECTED], http://twoshortplanks.com/};



Re: Learning regular expressions

2003-03-18 Thread Kris Boulez
Quoting Mark Fowler ([EMAIL PROTECTED]):
 On Mon, 17 Mar 2003, Phil Dobbin wrote:
 
  You can't go wrong with Jeffrey Friedl's `Mastering Regular Expressions'
  (O'Reilly: 1-56592-257-3).
 
 You'd be better off with the 2nd Edition.
 
 O'Reilly: 0-596-00289-0
 http://www.oreilly.com/catalog/regex2/
 
 Shouldn't someone be reviewing this for the site?
 
I just finished reading it (privately). I agree that if you're serious
about regexes, you should read this book. The second edition also
contains chapters on Java, VB.net, ..

Perl is still the main languange of this book though. After reading this
book I was able to speed up a regex we're using in production by a
factor of 4.


Kris,



Re: Learning regular expressions

2003-03-18 Thread Greg McCarroll
* Mark Fowler ([EMAIL PROTECTED]) wrote:
 On Mon, 17 Mar 2003, Phil Dobbin wrote:
 
  You can't go wrong with Jeffrey Friedl's `Mastering Regular Expressions'
  (O'Reilly: 1-56592-257-3).
 
 You'd be better off with the 2nd Edition.
 
 O'Reilly: 0-596-00289-0
 http://www.oreilly.com/catalog/regex2/
 
 Shouldn't someone be reviewing this for the site?
 

*looks down at the ground and shuffles feet nervously*

Greg

-- 
*** ***
***   Email address has changed to [EMAIL PROTECTED] . Please   ***
***   update your email address book.   ***
*** ***
Greg McCarroll http://www.mccarroll.org.uk/~gem/
   jabber://[EMAIL PROTECTED]



Re: Learning regular expressions

2003-03-18 Thread Marty Pauley
On Tue Mar 18 10:21:20 2003, Mark Fowler wrote:
 On Mon, 17 Mar 2003, Phil Dobbin wrote:
 
  You can't go wrong with Jeffrey Friedl's `Mastering Regular Expressions'
  (O'Reilly: 1-56592-257-3).
 
 You'd be better off with the 2nd Edition.

Or you could come to Belfast next Monday and hear Mark Jason Dominus
give his Perl Regular Expression Mastery course.

-- 
Marty



Re: Learning regular expressions

2003-03-18 Thread Phil Dobbin
On 18/3/03 10:21, Mark Fowler [EMAIL PROTECTED] wrote:

 On Mon, 17 Mar 2003, Phil Dobbin wrote:
 
 You can't go wrong with Jeffrey Friedl's `Mastering Regular Expressions'
 (O'Reilly: 1-56592-257-3).
 
 You'd be better off with the 2nd Edition.

[...]

Hey, I've bought thirty-two O'Reilly books as it is ;-)

Regards,

Phil.
-- 
for(reverse(1..100)){$s=($_==1)? '':'s';print$_ bottle$s of beer on the
wall,\n;
print$_ bottle$s of beer,\nTake one down, pass it around,\n;
$_--;$s=($_==1)?'':'s';print$_ bottle$s of beer on the
wall\n\n;}print'*burp*';





Re: Learning regular expressions

2003-03-18 Thread Chris Benson
On Tue, Mar 18, 2003 at 12:41:18PM +, Phil Dobbin wrote:

 Hey, I've bought thirty-two O'Reilly books as it is ;-)

I'll raise you: (gulp) forty-eight at home[*] including the 1988
(first?) edition of the X11 manuals.

I blame Josette. You can't turn round without getting a discount: London
PerlMounger - get a discount, Tyneside PerlMounger - get a discount,
UKUUG member - get a discount, ...

:-)

[*] implying an uncounted number at work ...
-- 
Chris Benson



Re: Learning regular expressions

2003-03-18 Thread Jon Reades
Jonathan Peterson wrote:
I assume that this was supposed to be:
 =~ m/\s*(?:y|(ok))/i


I did.


But this is hardly easier than 'eq'.

Easier for the programmer? Of course not! Heh, when I say better I mean
better for the user, and therefore a better bit of software. Programmers are
just staff, but users are people :-)
I agree that accepting  y,Y, my mother is all well and good 
from a usability standpoint, but I believe that the original context of 
this thread was simply whether or not regexs are hard and how well they 
perform (or, conversely, how poorly they perform when they aren't 
well-formed).

 To not do so is broken, end of story. It baffles me that some people 
think
 in the year 2003 it's OK to have software that does this:

I would agree with you on this, but it makes the assumption that we're 
discussing user-interactions. Funnily enough, my assumption was that 'y' 
came from some kind of flat-file in which it might be the result of some 
kind of form input (e.g. radio button) or log data, but I guess that's 
because I've spent too long working with ETL code and not people. ;)

jon

--
jon reades
fulcrum analytics
t: 0870.366.9338
m: 0797.698.7392
f: 0870.888.8880
lower ground floor
2 sheraton street
london w1f 8bh



Re: Learning regular expressions

2003-03-18 Thread Greg McCarroll
* Chris Benson ([EMAIL PROTECTED]) wrote:
 On Tue, Mar 18, 2003 at 12:41:18PM +, Phil Dobbin wrote:
 
  Hey, I've bought thirty-two O'Reilly books as it is ;-)
 
 I'll raise you: (gulp) forty-eight at home[*] including the 1988
 (first?) edition of the X11 manuals.
 
 I blame Josette. You can't turn round without getting a discount: London
 PerlMounger - get a discount, Tyneside PerlMounger - get a discount,
 UKUUG member - get a discount, ...
 
 :-)
 

/me sits in the corner looking smug

-- 
*** ***
***   Email address has changed to [EMAIL PROTECTED] . Please   ***
***   update your email address book.   ***
*** ***
Greg McCarroll http://www.mccarroll.org.uk/~gem/
   jabber://[EMAIL PROTECTED]



Re: Learning regular expressions

2003-03-18 Thread Dave Cross
On Tue, Mar 18, 2003 at 12:41:18PM +, Phil Dobbin ([EMAIL PROTECTED]) wrote:
 
 Hey, I've bought thirty-two O'Reilly books as it is ;-)

I quick count in the area round my desk at home finds 120 O'Reilly books.
There are others at work as well I think.

Dave...

-- 
  Brian: Oh screw Maximilian!
  Sally: I do.
  Brian: So do I.



Re: Learning regular expressions

2003-03-18 Thread Luis Campos de Carvalho
- Original Message -
From: Dave Cross [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 3:51 PM


 On Tue, Mar 18, 2003 at 12:41:18PM +, Phil Dobbin
([EMAIL PROTECTED]) wrote:
 
  Hey, I've bought thirty-two O'Reilly books as it is ;-)

 I quick count in the area round my desk at home finds 120 O'Reilly books.
 There are others at work as well I think.


  pedanticHey, Dave, do you work at a Book Store? =-]/pedantic

  Sorry, I can't resist...
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  Luis Campos de Carvalho
  Computer Science Student
  OCP DBA Oracle  Unix Sys Admin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Re: Learning regular expressions

2003-03-18 Thread David Cantrell
On Tuesday, March 18, 2003 11:29 + Greg McCarroll 
[EMAIL PROTECTED] wrote:
* Mark Fowler ([EMAIL PROTECTED]) wrote:
You'd be better off with the 2nd Edition.

O'Reilly: 0-596-00289-0
http://www.oreilly.com/catalog/regex2/
Shouldn't someone be reviewing this for the site?
*looks down at the ground and shuffles feet nervously*
You should have kept quiet, I wasn't going to be naming any names, what 
with me being the next person on the naughty list :-)

If you (and that's you plural, for anyone else who owes a book review) 
don't have the time to do a thorough review of a book that you've got, then 
a shorter review of your first impressions, or of a few selected chapters, 
would still be useful.

--
David Cantrell


Re: Learning regular expressions

2003-03-17 Thread Jon Reades
Work wrote:
snip
if($userinput eq 'y') ## yucky
{
...
}
Uh, why?

If all you care about is the case 'y' then this is a much better and 
faster way to determine the truth or falsehood of the statement. It's 
also, IMO, the clearest of all.

If you really wanted to handle a couple of differenct options, then how 
about:

my %is_ok = ('y' = 1, 'ok' = 1, 'Y' = 1, 'OK' = 1, 'Ok' = 1);

if ($is_ok{$userinput}) {
...
}
or

if ($is_ok{lc($userinput)}) {
...
}

if($userinput =~ /^\s*y|(ok)/i) # nice
{
...
}
Heh, heh, *this* is nice?

I assume that this was supposed to be:
 =~ m/\s*(?:y|(ok))/i
But this is hardly easier than 'eq'.

jon

--
jon reades
fulcrum analytics
t: 0870.366.9338
m: 0797.698.7392
f: 0870.888.8880
lower ground floor
2 sheraton street
london w1f 8bh



Re: Learning regular expressions

2003-03-17 Thread Shevek
On Mon, 17 Mar 2003, Jon Reades wrote:

 Work wrote:
 snip
  if($userinput eq 'y') ## yucky
  {
  ...
  }
 
 Uh, why?
 
 If all you care about is the case 'y' then this is a much better and 
 faster way to determine the truth or falsehood of the statement. It's 
 also, IMO, the clearest of all.
 
 If you really wanted to handle a couple of differenct options, then how 
 about:
 
 my %is_ok = ('y' = 1, 'ok' = 1, 'Y' = 1, 'OK' = 1, 'Ok' = 1);
 
 if ($is_ok{$userinput}) {
   ...
 }

Because it's annoying when you prefix your input with a space to have it 
rejected. I would strongly prefer the regex.

S.

 
 or
 
 if ($is_ok{lc($userinput)}) {
   ...
 }
 
 
  
  if($userinput =~ /^\s*y|(ok)/i) # nice
  {
  ...
  }
 
 Heh, heh, *this* is nice?
 
 I assume that this was supposed to be:
   =~ m/\s*(?:y|(ok))/i
 
 But this is hardly easier than 'eq'.
 
 jon
 
 

-- 
Shevekhttp://www.anarres.org/
I am the Borg. http://design.anarres.org/




Re: Learning regular expressions

2003-03-17 Thread Luis Campos de Carvalho
- Original Message -
From: Jon Reades [EMAIL PROTECTED]
Sent: Monday, March 17, 2003 12:09 PM


 Work wrote:
 snip
  if($userinput eq 'y') ## yucky
snip
 
  if($userinput =~ /^\s*y|(ok)/i) # nice
  {
  ...
  }

 Heh, heh, *this* is nice?

 I assume that this was supposed to be:
   =~ m/\s*(?:y|(ok))/i

 But this is hardly easier than 'eq'.

  I'm wondering if you're talking about the regular expression concept or
about the REGEXP pattern match weird-look into your code (Perl have bad
presentation/textual representation of regular expression operators?)

  Cheers.






Re: Learning regular expressions

2003-03-17 Thread Phil Dobbin
On 13/3/03 17:05, Adam C Auden [EMAIL PROTECTED] wrote:

 On Thu, 13 Mar 2003, Peter Sergeant wrote:
 
 This seems to be a recurring theme - regular expressions are hard. This
 is not my experience. After QBasic, Perl was the first language I
 learned, and regular expressions were a topic I found very easy (and
 there were plenty of topics I found hard, I'm sure). I wonder why it is
 some people find regexes such a mind-twister.
 
 Not sure you can give a complete answer to this one, however I for one
 find regular expressions tricky due to the lack of decent docs available
 for them - particularly lack of examples to work from.
 
 Now I know I should just go and buy a book, however if anyone has any
 links to sites which they have found of use it would be much appreciated.

[...]

You can't go wrong with Jeffrey Friedl's `Mastering Regular Expressions'
(O'Reilly: 1-56592-257-3).

Great read, too.

Regards,

Phil.
-- 
Arms my only ornament - my only rest, the fight.
-- Cervantes, Don Quixote.





Re: Learning regular expressions

2003-03-17 Thread Jonathan Peterson
 
  I assume that this was supposed to be:
=~ m/\s*(?:y|(ok))/i

I did.

 
  But this is hardly easier than 'eq'.


Easier for the programmer? Of course not! Heh, when I say better I mean
better for the user, and therefore a better bit of software. Programmers are
just staff, but users are people :-)

Any program that claims to accept the string y as input meaning 'yes'
(where there are limited alternatives, such as 'no' and 'maybe') must also
accept at least:

 y
 Y
yes
yes 

etc..

To not do so is broken, end of story. It baffles me that some people think
in the year 2003 it's OK to have software that does this:

 The program will now analyse the file foo.db. This may take several
hours. Type 'Yes' to continue or 'Quit' to abort the operation.
 y
 Please enter either 'Yes' or 'Quit'
 yes
 please enter either 'Yes' or 'Quit'

But I still see rubbish like this all the time. And we wonder why people
prefer GUI's ;-)

Jon




Re: Learning regular expressions

2003-03-17 Thread Jonathan Peterson
 
  I assume that this was supposed to be:
=~ m/\s*(?:y|(ok))/i

I did.

 
  But this is hardly easier than 'eq'.


Easier for the programmer? Of course not! Heh, when I say better I mean
better for the user, and therefore a better bit of software. Programmers are
just staff, but users are people :-)

Any program that claims to accept the string y as input meaning 'yes'
(where there are limited alternatives, such as 'no' and 'maybe') must also
accept at least:

 y
 Y
yes
yes 

etc..

To not do so is broken, end of story. It baffles me that some people think
in the year 2003 it's OK to have software that does this:

 The program will now analyse the file foo.db. This may take several
hours. Type 'Yes' to continue or 'Quit' to abort the operation.
 y
 Please enter either 'Yes' or 'Quit'
 yes
 please enter either 'Yes' or 'Quit'

But I still see rubbish like this all the time. And we wonder why people
prefer GUI's ;-)

Jon




Re: Learning regular expressions

2003-03-17 Thread David H. Adler
On Mon, Mar 17, 2003 at 03:24:05PM +, Shevek wrote:
 On Mon, 17 Mar 2003, Jon Reades wrote:
 
  Work wrote:
  snip
   if($userinput eq 'y') ## yucky
   {
   ...
   }
  
  Uh, why?
  
  If all you care about is the case 'y' then this is a much better and 
  faster way to determine the truth or falsehood of the statement. It's 
  also, IMO, the clearest of all.
  
  If you really wanted to handle a couple of differenct options, then how 
  about:
  
  my %is_ok = ('y' = 1, 'ok' = 1, 'Y' = 1, 'OK' = 1, 'Ok' = 1);
  
  if ($is_ok{$userinput}) {
  ...
  }
 
 Because it's annoying when you prefix your input with a space to have it 
 rejected. I would strongly prefer the regex.

If all you care about is that there *is* a 'y', wouldn't index() solve
that problem (and possibly be more efficient than a regex?)

Or did someone mention that already and I'm just in desperate need of
sleep?

dha

-- 
David H. Adler - [EMAIL PROTECTED] - http://www.panix.com/~dha/
It's amazing what giant mutant ants that are the result of Man's
dabbling with the power of atomic energy can accomplish when they set
themselves to the task.- Mark Rogaski



Re: Learning regular expressions

2003-03-14 Thread Mark Fowler
On Thu, 13 Mar 2003, Adam C Auden wrote:

 Not sure you can give a complete answer to this one, however I for one
 find regular expressions tricky due to the lack of decent docs available
 for them - particularly lack of examples to work from.

The perlre the traditional documentation came with Perl isn't really a
beginers guide or a tutorial.  For that you need to see the perlrequick
guide that ships with perl 5.8.0.

  http://search.cpan.org/author/JHI/perl-5.8.0/pod/perlrequick.pod

Then you need to go onto the full blown tutorial that is perlretut

  http://search.cpan.org/author/JHI/perl-5.8.0/pod/perlretut.pod

All praise Mark Kvale for his hard work here.

Mark.

-- 
#!/usr/bin/perl -T
use strict;
use warnings;
print q{Mark Fowler, [EMAIL PROTECTED], http://twoshortplanks.com/};



Re: Learning regular expressions

2003-03-14 Thread Work
I think that Regexps are hard to learn because the most part of the
folks
  that aren't too much scared to learn it just lack the essential and
  unavoidable compiler theory where regexp lays its foundations. IMHO, its
  simply impossible learn good quality regexp use unless you have good
regular
  grammars theory before.

 No, that's WRONG. Again, I can only give myself as an example, but, I
 had no compiler theory or regular grammars theory. Regular expressions
 MAKE SENSE - in (again) my humble experience, it tends to be people who
 started with C or somesuch language who have the most difficulty with
 them. Go figure.

I agree that regexps seem to 'click' quite rapidly with some people, and
simply remain opaque for a long time with other people. I'm not sure why
this is. The owl book is excellent, but it also tends to make people think
These regexps are really powerful, but really complex - I'll live without
them.

I currently spend a lot of time trying to get Java programmers to use more
regexps. They all love the power and ability they have, but find them hard
to debug and so tend not to use them, or get frustrated easily. Java's poor
implementation* doesn't help.

However, I disagree that you need to understand the magic bahind regexps to
use them. The main strengths of regexps, esp. in their Perl implementation
is easy of use:

if($userinput eq 'y') ## yucky
{
...
}

if($userinput =~ /^\s*y|(ok)/i) # nice
{
...
}

Later, the expert user can start to learn more about how the engine works,
in order to craft more complex regexps.

*Using the various add on libraries for Java 1.2, which are either feature
poor (apache) or just really annoying in a stupid java-y way(gnu).




Re: Learning regular expressions

2003-03-14 Thread Jasper McCrea
Work wrote:
 
 if($userinput =~ /^\s*y|(ok)/i) # nice
 {
 ...
 }
 
Going some way to prove that regexps are complicated (for me, anyway), this does
not do what I thought it would.

/foo|bar/ matches foo or bar, obviously.

/foo|(bar)/ (as in the yes/ok case above) matches totally different stuff.

Although I've only been using regexps for 4+ years, and don't remember seeing
this behaviour before. If I have seen it, I must have spurned it, thinking I
must use parentheses better than that.

Jasper
-- 
We got Deathstar (Deathstar),
We got Deathstar (Deathstar),
We got Deathstar (Deathstar),
And you know that we got it.



Re: Learning regular expressions

2003-03-14 Thread Jasper McCrea
Jasper McCrea wrote:
 
 Work wrote:
 
  if($userinput =~ /^\s*y|(ok)/i) # nice
  {
  ...
  }
 
 Going some way to prove that regexps are complicated (for me, anyway), this does
 not do what I thought it would.
 
 /foo|bar/ matches foo or bar, obviously.
 
 /foo|(bar)/ (as in the yes/ok case above) matches totally different stuff.
 

Never mind, I was confused, as usual. I didn't think it could possibly be
working as (I thought it was) intended.

But it sort of proves the point, anyway, in that Mr Peterson wrote his regexp
wrong.

If he didn't mean

/^\s*(y|ok)/i

I apologise.

Jasper
-- 
$='';{split//,ajpsa onhtrep re lahkcre}foreach(0..$#_){
unless($_%2){$_[$_]^=$_[++$_]^=$_[--$_]^=$_[++$_]}}print@_\n



Re: Learning regular expressions

2003-03-14 Thread Luis Campos de Carvalho
- Original Message -
From: Work [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 8:02 AM


   [...] its foundations. IMHO, its simply impossible
   learn good quality regexp use unless you have
   good regular grammars theory before.
 
  No, that's WRONG. Again, I can only give myself
  [...] Regular expressions MAKE SENSE - in (again)
  my humble experience, it tends to be people who
  started with C [...]

 I agree that regexps seem to 'click' quite rapidly with
 some people, and simply remain opaque for a long time
 with other people. I'm not sure why this is. The owl
 book is excellent, but it also tends to make people think
 These regexps are really powerful, but really complex -
 I'll live without them.

  Well, you're right: I have seen folks that just can't use regexp because
they don't have clicked yet... pretty sad, I think.

 I currently spend a lot of time trying to get Java
 programmers to use more regexps. They all love the
 power and ability they have, but find them hard
 to debug and so tend not to use them, or get
 frustrated easily. Java's poor implementation* doesn't help.

  Maybe the frustration can be avoided with a little quick'n'dirty compiler
theory. This will make regexps easyer to debug, too, because you will start
to understand the internals. Try the Aho, Sethi  Ullman's Dragon Book
(Compilers: Principles, Techniques and Tools), chapters one, two and
three.

http://www.amazon.co.uk/exec/obidos/ASIN/0201100886/qid=1047649342/sr=1-1/re
f=sr_1_3_1/026-0411912-1523638

 However, I disagree that you need to understand
 the magic bahind regexps to use them. The main
 strengths of regexps, esp. in their Perl implementation
 is easy of use[...]

  Ok, ok. =-] You're right.
  What you don't know don't hurts you

 Later, the expert user can start to learn more
 about how the engine works, in order to craft
 more complex regexps.

  This is essential to use the full power of regular expression.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  Luis Campos de Carvalho
  Computer Science Student
  OCP DBA Oracle  Unix Sys Admin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Re: Learning regular expressions

2003-03-14 Thread Jonathan Peterson
 But it sort of proves the point, anyway, in that Mr Peterson wrote his
regexp
 wrong.

Yup.

 If he didn't mean

 /^\s*(y|ok)/i


Yeah, that's what I wanted to write. Stupid precedence rules - Perl didn't
do what I meant! :-P

However, I suggest that the debug cycle incurred by mis-use of regexps as I
just did is still preferable to the mis-funcationality that would have been
implemented otherwise.

Inadequate user input checking still plagues computer applications, and good
use of regexps would go some way to helping this.




Re: Learning regular expressions

2003-03-14 Thread David Cantrell
On Thu, Mar 13, 2003 at 04:24:16PM +, Peter Sergeant wrote:
 I wonder why it is some people find regexes such a mind-twister.

Trying to run before they can walk?  Some of the new stuff confuses the
hell out of me still, but then almost all my regex needs could be fulfilled
even by perl4.  I mostly use 'em as a glorified index().  Because I'm lazy.

-- 
Lord Protector David Cantrell | http://www.cantrell.org.uk/david

[OS X] appeals to me as a monk, a user, a compiler-of-apps, a
sometime coder, and an easily amused primate with a penchant
for those that are pretty, colorful, and make nice noises.
-- Dan Birchall, in The Monastery



Re: Learning regular expressions

2003-03-13 Thread Aaron Trevena
On Thu, 13 Mar 2003, Peter Sergeant wrote:
  If you've never heard of grep, glob, split, local/gmtime,  unlink,
  STDIN, ARGV, ... or seen a regular expression, it's all pretty
  bewildering.   Even if you have, there's all the chop/chomp/splice/...
  cuteness to confuse.

 This seems to be a recurring theme - regular expressions are hard. This
 is not my experience. After QBasic, Perl was the first language I
 learned, and regular expressions were a topic I found very easy (and
 there were plenty of topics I found hard, I'm sure). I wonder why it is
 some people find regexes such a mind-twister.

I think there are two causes of this :
 - people don't see a regex as a function (something familar to every
language) they see it as some kind of magic and fear it because it is
different to what they have done before.
 - some of the newer (weaker ;) generation lack practice of the
traditional problem space that programming has applied to - processing
text and data, I think I can program quite well because I find pattern
matching and finding relatively easy so regular expressions make perfect
sense, newer programmers focus on mouse clicks, using objects and xml to
get what they want out of an xml structure or using a cursor with methods
to fetch data.

The latter are the kind of people who are used to perhaps building ASP
type pages where the programming consists of calling a load of functions
inside some html, no structure, no text handling - and they do have to
write application logic its usually horrible twisted spagetti or embedded
into stored_procedures in even more hideous code.

A.


-- 
Aaron J Trevena - Perl Hacker, Kung Fu Geek, Internet Consultant
AutoDia --- Automatic UML and HTML Specifications from Perl, C++
and Any Datasource with a Handler. http://droogs.org/autodia




Re: Learning regular expressions

2003-03-13 Thread Adam C Auden
On Thu, 13 Mar 2003, Peter Sergeant wrote:

 This seems to be a recurring theme - regular expressions are hard. This
 is not my experience. After QBasic, Perl was the first language I
 learned, and regular expressions were a topic I found very easy (and
 there were plenty of topics I found hard, I'm sure). I wonder why it is
 some people find regexes such a mind-twister.

Not sure you can give a complete answer to this one, however I for one
find regular expressions tricky due to the lack of decent docs available
for them - particularly lack of examples to work from.

Now I know I should just go and buy a book, however if anyone has any
links to sites which they have found of use it would be much appreciated.

Other then this, whilst regular expressions can be very powerful tools,
they are not the most accessible (Write Once, Read Never is often the case
for particularly complex ones) which makes the routine of reading other
people's code to learn how it works a trickier one to approach.

Having spent most of today wielding sed I think I'm slowly getting the
hang of them, but my knowledge is only a small subset I am sure.  RegExs
are a brick wall I will continue to bash my head against, however I don't
see the learning curve getting any easier.

A.

--
aca114



Re: Learning regular expressions

2003-03-13 Thread Lusercop
On Thu, Mar 13, 2003 at 04:24:16PM +, Peter Sergeant wrote:
 This seems to be a recurring theme - regular expressions are hard. This
 is not my experience. After QBasic, Perl was the first language I

aol (apart from the qbasic bit)

-- 
Lusercop.net - LARTing Lusers everywhere since 2002



Re: Learning regular expressions

2003-03-13 Thread Luis Campos de Carvalho

 On Thu, 13 Mar 2003, Peter Sergeant wrote:
  [...] I wonder why it is
  some people find regexes such a mind-twister.

 From: Adam C Auden [EMAIL PROTECTED]
 Sent: Thursday, March 13, 2003 2:05 PM
 Not sure you can give a complete answer to this one,
 however I for one find regular expressions tricky due
 to the lack of decent docs available for them -
 particularly lack of examples to work from.

  I disagree. Regexps are quite well documented. There is even a manpage
exclusively dedicated to it. =-]

  I think that Regexps are hard to learn because the most part of the folks
that aren't too much scared to learn it just lack the essential and
unavoidable compiler theory where regexp lays its foundations. IMHO, its
simply impossible learn good quality regexp use unless you have good regular
grammars theory before.

 Other then this, whilst regular expressions can
 be very powerful tools, they are not the most
 accessible (Write Once, Read Never is often the
 case for particularly complex ones) which makes the
 routine of reading other people's code to learn
 how it works a trickier one to approach.

  Sorry, I disagree on you again. =-]
  Folks that write regexps and do not optimize source code for reading
(e.g.: using the 'x' option) are building a maintenance nightmare. Regexps
are as powerfull as dynamite: you should handle them with care, or you will
blow everything up soon or later. =-]
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  Luis Campos de Carvalho
  Computer Science Student
  OCP DBA Oracle  Unix Sys Admin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Re: Learning regular expressions

2003-03-13 Thread Peter Sergeant
   I disagree. Regexps are quite well documented. There is even a manpage
 exclusively dedicated to it. =-]

Though actually most of the docs used to be split between perlop and
perlre, neither of which are friendly pieces of text. I believe this
situation has ameliorated a little, but, certainly the docs were
traditionally kinda sucky.

   I think that Regexps are hard to learn because the most part of the folks
 that aren't too much scared to learn it just lack the essential and
 unavoidable compiler theory where regexp lays its foundations. IMHO, its
 simply impossible learn good quality regexp use unless you have good regular
 grammars theory before.

No, that's WRONG. Again, I can only give myself as an example, but, I
had no compiler theory or regular grammars theory. Regular expressions
MAKE SENSE - in (again) my humble experience, it tends to be people who
started with C or somesuch language who have the most difficulty with
them. Go figure.

+Pete

-- 
Much may be made of a Scotchman, if he be caught young.
 -- Samuel Johnson