StringTools
MatchFence
find the matching fence character to one in a string of text
Calling Sequence
Parameters
Description
Examples
MatchFence( s, pos )
s
-
string; string to examine
pos
posint; the position of a fence character in the string s
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 spos is not a fence character, that is, not one of (,),[,],{,}, 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.
with⁡StringTools:
MatchFence⁡ab{cde}fg,3
7
n≔MatchFence⁡ab(cde)fg,3
n≔7
MatchFence⁡ab(cde)fg,n
3
MatchFence⁡ab(cde)fg,1
Error, (in StringTools:-MatchFence) the character `a' is not a fence character
MatchFence⁡ab[cdefg,3
0
MatchFence⁡ab{cde]fg,3
See Also
string
StringTools[IsBalanced]
Download Help Document