 MatchFence - Maple Help

StringTools

 MatchFence
 find the matching fence character to one in a string of text Calling Sequence MatchFence( s, pos ) Parameters

 s - string; string to examine pos - posint; the position of a fence character in the string s Description

 • The MatchFence procedure locates the matching fence character to one specified in the input text s by its position pos. It returns the position, in s, of the matching fence character if present, or $0$ otherwise. If ${s}_{\mathrm{pos}}$ is not a fence character, that is, not one of $\left\{"\left(","\right)","\left[","\right]","\left\{","\right\}"\right\}$, an exception is raised.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings. Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{MatchFence}\left("ab\left\{cde\right\}fg",3\right)$
 ${7}$ (1)
 > $n≔\mathrm{MatchFence}\left("ab\left(cde\right)fg",3\right)$
 ${n}{≔}{7}$ (2)
 > $\mathrm{MatchFence}\left("ab\left(cde\right)fg",n\right)$
 ${3}$ (3)
 > $\mathrm{MatchFence}\left("ab\left(cde\right)fg",1\right)$
 > $\mathrm{MatchFence}\left("ab\left[cdefg",3\right)$
 ${0}$ (4)
 > $\mathrm{MatchFence}\left("ab\left\{cde\right]fg",3\right)$
 ${0}$ (5)