Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!CITHEX.CALTECH.EDU!carl From: carl@CITHEX.CALTECH.EDU (Carl J Lydick) Newsgroups: comp.os.vms Subject: Re: question on patterns and pattern operators in TPU Message-ID: <880313023832.53f@CitHex.Caltech.Edu> Date: 13 Mar 88 10:44:43 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 24 > I would like some clarification about patterns and pattern operators in TPU; > specifically, the | operator. If I am interpreting the TPU manual correctly, > the line > > PAT := ' ' | LINE_BEGIN; > > ought to make a pattern PAT that will match on either a space or a > beginning-of-line. If, however, I follow this line with the lines > > WORDSTART := SEARCH (PAT, REVERSE); > POSITION (WORDSTART); > > I always go to a space and never to the beginning of a line, even when > the beginning of a line is closer. You're suffering from one of the wierdnesses of TPU. Given the pattern you've specified, TPU will search that part of the file following your current position for a ' ', and if it doesn't find one, will search it for a LINE_BEGIN. This is definitely NON-INTUITIVE, and therefore, probably a bad default (hey DEC, anybody listening out there [though it's far too late to fix this problem now]). What you need to do is make the pattern: PAT := '' & ( ' ' | LINE_BEGIN ) ; This forces it to find '' every character and look for ( ' ' | LINE_BEGIN ) as the succeeding character in all cases.