From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mod.civil.su.OZ.AU ([129.78.142.6]) by hawkwind.utcs.toronto.edu with SMTP id <2748>; Sat, 20 Feb 1993 03:08:45 -0500 Received: by mod.civil.su.oz.au id <28687>; Sat, 20 Feb 1993 19:08:34 +1100 From: John Mackin Date: Sat, 20 Feb 1993 02:52:09 -0500 To: Sam Fans Subject: A point about ^ and $ in sam regexps Message-ID: <199302201852.6794.sam.badab@civil.su.oz.au> X-Face: 39seV7n\`#asqOFdx#oj/Uz*lseO_1n9n7rQS;~ve\e`&Z},nU1+>0X^>mg&M.^X$[ez>{F k5[Ah<7xBWF-@-ru?& @4K4-b`ydd^`(n%Z{ 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.