DISCLOSE
s = DISCLOSE (str [, pairs [, ignore-pairs]])
Discloses the string str
. pairs
is a string
of 2n characters. Two consecutive characters form a pair. The characters
of str
which are positioned between the first matching pair
of pairs
will be returned. ignore-pairs
is a
string with 2n characters. Two consecutive characters form a
ignore-pair. All characters of str
between an ignore-pair
will be ignored (not returned).
if pairs
and ingnore-pairs
are not given,
the following default pairs and ignore pairs will be used:
First non white-space character | Check | Ignore |
---|---|---|
” | ” ” | ’ ’ |
’ | ’ ’ | ” ” |
( | () | ” ” ’ ’ |
[ | [] | ” ” ’ ’ |
{ | {} | ” ” ’ ’ |
< | <> | ” ” ’ ’ |
Example 1: Disclose default pairs
"(abc)"
s = print disclose(s) ' Output: abc
Example 2: Disclose non-default pairs
"_abc_"
s = print disclose(s, "__") ' Output: abc
"([abc])"
s = print disclose(s, "[]") ' Output: abc
"([abc])"
s = print disclose(s, "[)") ' Output: abc]
"[(abc)]"
s = print disclose(s, "()[]") ' Output: (abc)
"abc (def)"
s = print disclose(s, "()") ' Output: def
"abc (d(ef))"
s = print disclose(s, "()") ' Output: d(ef)
Example 3: Disclose with ignore-pairs
"abc [d(ef)] (gh)"
s = print disclose(s, "()", "[]") ' Output: gh
Code samples using DISCLOSE