sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
* A point about ^ and $ in sam regexps
@ 1993-02-20  7:52 John Mackin
  0 siblings, 0 replies; only message in thread
From: John Mackin @ 1993-02-20  7:52 UTC (permalink / raw)
  To: Sam Fans

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1993-02-20  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-02-20  7:52 A point about ^ and $ in sam regexps John Mackin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).