Xref: utzoo comp.unix.questions:30636 comp.unix.wizards:25056 comp.unix.internals:2592 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions,comp.unix.wizards,comp.unix.internals Subject: Re: Would somebody please explain? Message-ID: <7323@auspex.auspex.com> Date: 22 Apr 91 18:05:00 GMT References: <1991Apr21.001702.5661@umbc3.umbc.edu> <1991Apr21.023416.5795@mp.cs.niu.edu> Followup-To: comp.unix.questions Organization: Auspex Systems, Santa Clara Lines: 48 > From the output I would guess that 'match', 'index', 'substr' and 'length' >are builin functions or operators for 'expr', They are. >although they are not documented in any man pages that I have seen. The original V7 "expr" had all of 'em built in. The SunOS 4.0.3 manual page documents them: string : regular-expression match string regular-expression The two forms of the matching operator above are synonymous. The matching operators : and match compare the first argument with the second argument which must be a regular expression. Regular expression syntax is the same as that of ed(1), except that all patterns are anchored (treated as if they begin with ^) and, therefore, ^ is not a special character, in that con- text. Normally, the matching operator returns the number of characters matched (0 on failure). Alterna- tively, the \(...\) pattern symbols can be used to return a portion of the first argument. substr string integer-1 integer-2 Extract the subtring of string starting at position integer-1 and of length integer-2 characters. If integer-1 has a value greater than the length of string, expr returns a null string. If you try to extract more characters than there are in string, expr returns all the remaining characters from string. Beware of using negative values for either integer-1 or integer-2 as expr tends to run forever in these cases. index string character-list Report the first position in string at which any one of the characters in character-list matches a character in string. length string Return the length (that is, the number of characters) of string. The S5 version ripped "substr", "index", and "length" out - probably to avoid the problem reported in the original posting - but kept "match" as an alias for ":", for reasons not obvious to me (considering that doing so means that the problem reported in the original posting is *NOT* avoided).