Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!genrad!grkermit!mit-vax!eagle!hou5h!hou5a!hou5d!hogpc!houxm!ihnp4!ixn5c!inuxc!pur-ee!uiucdcs!mcdaniel From: mcdaniel@uiucdcs.UUCP Newsgroups: net.bugs.4bsd Subject: Re: Reg Expr bugs in vi? - (nf) Message-ID: <3038@uiucdcs.UUCP> Date: Thu, 29-Sep-83 22:25:57 EDT Article-I.D.: uiucdcs.3038 Posted: Thu Sep 29 22:25:57 1983 Date-Received: Sun, 2-Oct-83 03:33:13 EDT Lines: 62 #R:uiuccsb:6300001:uiucdcs:8200014:000:2596 uiucdcs!mcdaniel Sep 29 20:30:00 1983 tektroni!davec's comments are preceded by > below. > . . . On the input >skd jflksd jfsdlk >llkwejrlkw hllejrljlkajioerumm >jlrkwejrkw2345kld';l./,l sdfl > >you said that the following search patterns all seem to behave the same way. >/^[a-z] >/.*[a-z] >/[a-z].* > >And well they should. Perhaps you are confusing shell syntax with regular >expression syntax. The combination ".*" will match anything of any length. >Thus the 1st example will find the first line that starts with the letters >a-z; the second and third will find the first lowercase letter after the >cursor. No, he's not confusing it with shell syntax. The second and third examples DO NOT "find the first lowercase letter after the cursor." They should match, respectively, a string as long as possible of arbitrary characters (except /n) followed by an alpha, and an alpha followed by a SALAPOAC(E/n), both starting just after the cursor. If you start in the middle of a line and do either of the two, it matches the entire NEXT LINE. It should match the REMAINING text on the current line. >Your second example, At least third (8th if you count all REs -- unless you have a different numbering system). Why didn't you consider his second example? >/,.*[0-9] >instead of >/,*[0-9] >works like this: the first example will find the first line with a comma >and a number in it. As noted above, it should not "find a line". It should match text, on the CURRENT LINE if possible (and move the cursor to the start of the matched text). About his example of "/3*[a-z]" ("second" example): TRY it on the example text. You know what will happen (at least in vi "Version 3.6, 11/3/80")? It will move the cursor in 2 character increments. "/[a-z]3*" moves the cursor in 1 character increments. Why 2 CI in one, 1 CI in the other? Now, about '"/3*" moves the cursor by two chars . . . ' [Emrath]. Again, why move by two? Also, why does it stop at the end of the line? Why not go on to the next line? (It does not seem to stop at a blank line, as he indicates.) >Playing with regular expressions can be tricky. Perhaps before you yell >"bug" you should explain exactly what you were trying to do rather than >what you did. Indeed. Couldn't agree more. Perhaps before *YOU* yell "you're wrong", you should try the examples first, hmmmmm? (Should I? Well, he was stupid enough not to check it out first -- why not?) you stupid drip. Tim McDaniel, University of Illinois at Urbana-Champaign, CS dept. (UNIX mail: . . . pur-ee!uiucdcs!mcdaniel) (CSNET: mcdaniel.uiuc@RAND-RELAY)