Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxl.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!mhuxt!houxm!whuxl!mike From: mike@whuxl.UUCP (BALDWIN) Newsgroups: net.unix Subject: Re: KSH substring function (is it on your system?) Message-ID: <813@whuxl.UUCP> Date: Wed, 13-Nov-85 23:49:07 EST Article-I.D.: whuxl.813 Posted: Wed Nov 13 23:49:07 1985 Date-Received: Fri, 15-Nov-85 04:47:29 EST References: <121@rruxc.UUCP> <9@pixutl.UUCP> Organization: AT&T Bell Laboratories, Whippany Lines: 28 > As long as we're talking about 'substring', 'expr' has a 'substr' option > that used to be documented in V6. > > It goes: > expr substr string n m > > where n is the first character of the sub-string and m the length. > > so: expr substr abcdefgh 2 4 > gives: bcde > > 'expr' also has 'match', 'lentgh', and 'index' options that are not > documented any longer. Anyone knows why? The ":" operator of expr now handles all of these cases (I've never heard of "index"; what does it do?): -- old -- -- new -- expr match string regexp expr string : regexp expr length string expr string : '.*' expr substr string off len expr string : '.\{off-1\}\(.\{len\}\)' Of course, you have to make sure that "string" isn't a valid expr operator. Putting an ordinary char like _ at the beginning of both the string and the regexp will fix that. -- Michael Baldwin {at&t}!whuxl!mike