Skip to content

Commit 7b4c205

Browse files
authored
Update 777-string-disclose.markdown
1 parent c948f1d commit 7b4c205

1 file changed

Lines changed: 33 additions & 14 deletions

File tree

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# DISCLOSE
22

3-
> DISCLOSE (str[, pairs [, ignore-pairs]])
3+
> s = DISCLOSE (str [, pairs [, ignore-pairs]])
44
5-
Discloses a string.
5+
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).
66

7-
Default pairs and ignore pairs
7+
if `pairs` and `ingnore-pairs` are not given, the following default pairs and ignore pairs will be used:
88

99
| First non white-space character | Check | Ignore |
1010
|---------------------------------|-------|---------|
@@ -14,20 +14,39 @@ Default pairs and ignore pairs
1414
| [ | [] | " " ' ' |
1515
| { | {} | " " ' ' |
1616
| < | <> | " " ' ' |
17-
| " | " " | ' ' |
1817

19-
## Example
18+
## Example 1: Disclose default pairs
19+
20+
```
21+
s = "(abc)"
22+
print disclose(s) ' Output: abc
23+
```
24+
25+
### Example 2: Disclose non-default pairs
26+
27+
```
28+
s = "_abc_"
29+
print disclose(s, "__") ' Output: abc
30+
31+
s = "([abc])"
32+
print disclose(s, "[]") ' Output: abc
33+
34+
s = "([abc])"
35+
print disclose(s, "[)") ' Output: abc]
2036
37+
s = "[(abc)]"
38+
print disclose(s, "()[]") ' Output: (abc)
39+
40+
s = "abc (def)"
41+
print disclose(s, "()") ' Output: def
42+
43+
s = "abc (d(ef))"
44+
print disclose(s, "()") ' Output: d(ef)
2145
```
22-
s = "abc (abc)"
23-
? "1. "; s; tab(20); " -> "; disclose(s, "()") ' prints abc
2446

25-
s = "abc (a(bc))"
26-
? "2. "; s; tab(20); " -> "; disclose(s, "()") ' prints a(bc)
27-
? "3. "; s; tab(20); " -> "; disclose(disclose(s, "()"), "()") ' prints bc
47+
### Example 3: Disclose with ignore-pairs
2848

29-
s = "abc (a='(bc)')"
30-
? "4. "; s; tab(20); " -> "; disclose(s, "()", "''") ' prints a='(bc)'
31-
? "5. "; s; tab(20); " -> "; disclose(disclose(s, "()", "''"), "()", "''")
32-
' prints nothing
49+
```
50+
s = "abc [d(ef)] (gh)"
51+
print disclose(s, "()", "[]") ' Output: gh
3352
```

0 commit comments

Comments
 (0)