Subject: A point about ^ and $ in sam regexps

From: John Mackin <[email-masked]>
Date: Sat, 20 Feb 1993 02:52:09 -0500

In Rob's paper `Structural Regular Expressions,' found in doc/se.ps
in recent distributions of sam by ftp from research.att.com (I don't think
it was there in the version that was put up right at the beginning),
there is the following statement on p. 4:

	The program to capitalize `i's should be writable as

	    x/[A-Za-z]+/ g/^i$/ c/I/

    That is, the definition of ^ and $ should reflect the structure
    of the input.  For compatibility and because of some problems in
    the implementation, however, ^ and $ in sam always match line
    boundaries.

When I first read this I distantly agreed with it.  Distantly because
I remember some years ago when first learning to edit with sam's command
language being often frustrated by the fact that ^ and $ couldn't be
persuaded to match the beginning and end of a structural piece rather
than a line boundary; only distantly since it's been a long time since
I felt the need to do that, and I find I have no requirement for it
any more, having learned to think in the way the command language works.

The point of this mail is that this morning I had what seems to me a
definite need for the way it works at the moment, and therefore I thought
I should put in a positive word for always matching a line boundary --
or perhaps someone will tell me a nicer way to do this without using
that feature.  I had some text (whole lines) selected which was indented
by several spaces on each line.  I wanted to reduce all embedded runs of
spaces to single spaces without affecting the indentation.  The command

	x/ +/ v/^/ c/ /

came naturally to hand, and of course worked as I wanted.  Would there be as
natural a way of expressing this if the meaning of ^ were to change?

OK,
John.