Reg Expr bugs in vi? - (nf)

Dave Clemans davec at tektronix.UUCP
Thu Sep 29 00:52:48 AEST 1983


The examples you gave worked perfectly correctly. 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.

Your 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. Both
,0
and
,ldfjljlsajfldfjlfasjfj0
will be found by that pattern.

The second will find only a line with a number in it,
because '*' can match null too. It could conceivably find a line of the type
,,,,,,,,,,,,,,,,,,,,,,,1
also, but it would also work on
1

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.

Rick Lindsley
richl at tektronix
...!tektronix!richl



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