## $PIECE## 1995 Version of ANSI (Equivalent to Current ISO Version) of Standard |

$P[IECE] ( __expr___{1} ,
__expr___{2} )

This form is defined here with the aid of a function, NF,
which is used for definitional purposes only, called *find the
position number following the* m*th occurrence*.

NF(*s*,*d*,*m*) is defined, for strings
*s*, *d*, and integer *m*, as follows:

- When
*d*is the empty string, the result is zero. - When
*m*'> 0, the result is zero. - When
*d*is not a substring of*s*, i.e., when $F(*s*,*d*) = 0, then the result is $L(*s*) + $L(*d*) + 1. - Otherwise, NF(
*s*,*d*,1) = $F(*s*,*d*). - For
*m*> 1, NF(*s*,*d*,*m*) = NF($E(*s*,$F(*s*,*d*),$L(*s*)),*d*,*m*–1) + $F(*s*,*d*) - 1. - That is, NF extends $Find to give the position
number of the character to the right of the
*m*th occurrence of the string*d*in*s*.

Let *s* be the value of __expr___{1}, and let
*d* be the value of __expr___{2}.
$Piece(*s*,*d*) returns the substring of *s*
bounded on the right but not including the first (leftmost)
occurrence of *d*.

$P(*s*,*d*) = $E(*s*,0,NF(*s*,*d*,1) -
$L(*d*) - 1).

$P[IECE] ( __expr___{1} ,
__expr___{2} , __intexpr__ )

Let *m* be the integer value of __intexpr__.
$Piece(*s*,*d*,*m*) returns the substring
of *s* bounded by but not including the *m–1*th and the
*m*th occurrence of *d*.

$P(*s*,*d*,*m*) =
$E(*s*,NF(*s*,*d*,*m*–1),NF(*s*,*d*,*m*)
- $L(*d*) - 1).

$P[IECE] ( __expr___{1} ,
__expr___{2} , __intexpr___{1} ,
__intexpr___{2} )

Let *n* be the integer value of
__intexpr___{2}.
$Piece(*s*,*d*,*m*,*n*) returns the
substring of *s* bounded on the left but not including the
*m–1*th occurrence of *d* in *s*, and bounded on
the right but not including the *n*th occurrence of *d*
in *s*.

$P(*s*,*d*,*m*,*n*) =
$E(*s*,NF(*s*,*d*,*m*–1),NF(*s*,*d*,*n*)
- $L(*d*) - 1).

Note that $P(*s*,*d*,*m*,*m*) =
$P(*s*,*d*,*m*), and that $P(*s*,*d*,1)
= $P(*s*,*d*).

Copyright © Standard Documents; 1977-2018 MUMPS Development Committee;

Copyright © Examples: 1995-2018 Ed de Moel;

Copyright © Annotations: 2003-2008 Jacquard Systems Research

Copyright © Annotations: 2008-2018 Ed de Moel.

This page most recently updated on 13-Sep-2014, 17:20:54 .

For comments, contact Ed de Moel (demoel@jacquardsystems.com)