Reg Expr bugs in vi? - (nf)

mcdaniel at uiucdcs.UUCP mcdaniel at uiucdcs.UUCP
Fri Sep 30 12:25:57 AEST 1983


#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 at RAND-RELAY)



More information about the Comp.bugs.4bsd.ucb-fixes mailing list