some undocumented `expr' operators

utzoo!decvax!decwrl!sun!megatest!fortune!hpda!hplabs!hao!seismo!harpo!floyd!vax135!cornell!uw-beaver!teltone!stan utzoo!decvax!decwrl!sun!megatest!fortune!hpda!hplabs!hao!seismo!harpo!floyd!vax135!cornell!uw-beaver!teltone!stan
Tue May 10 17:12:46 AEST 1983


I accidentally discovered some undocumented operators available with the
expr command.

  The operators are length, substr, match, and index:
	expr length <string>	will return the integer length of <string>
	expr substr <string> <integer1> <integer2>
				will extract the substring of <string>
				that begins at position <integer1> and
				is of length <integer2>
	expr match <string> <reg-expr> 	  {same as documented ':' operator}
				will report no. of characters matched by
				searching <string> with the regular expression
	expr index <string> <character-list>
				will report the first position in <string>
				at which any one of the characters in the 
				<character-list> matches

Even if these operators are of no use to you, note that you can't use
any of the operators as ordinary strings to test on (this fact led to
their discovery).

Could someone with access to sources verify that the above is correct
and also find out what arguments are valid or invalid (e.g., if substr
is given negative arguments, it runs forever).



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