sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: John Mackin <john@civil.su.oz.au>
To: Sam Fans <sam-fans@hawkwind.utcs.toronto.edu>
Subject: A point about ^ and $ in sam regexps
Date: Sat, 20 Feb 1993 02:52:09 -0500	[thread overview]
Message-ID: <199302201852.6794.sam.badab@civil.su.oz.au> (raw)

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.


                 reply	other threads:[~1993-02-20  8:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199302201852.6794.sam.badab@civil.su.oz.au \
    --to=john@civil.su.oz.au \
    --cc=sam-fans@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).