Subversion Repositories wimsdev

Rev

Rev 11219 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2071 zjchen 1
!! +exec+ +var+ +string+
11219 bpr 2
tit:text
3
type:$type_both
4
syntax:!text `operation' `parameter'
5
mean:这是极其有力的文本操作工具,\
17228 bpr 6
  可以快速地对很长的文字串作复杂的处理. <br>\
11219 bpr 7
  许多操作 `operation' 能使用掩码(mask). 掩码是一个 '0' '1' 序列.\
8
  对于接受掩码的操作, 只对掩码为 '1' 的位置的字符作处理\
9
  (这相当于`掩盖''0' 对应的字符).\
17228 bpr 10
  空的掩码相当于全部由 '1' 构成. <br>\
11219 bpr 11
  太短的掩码将被重复使用, 除非它的结尾为 '+', 这时剩下的全取为 '1',\
17228 bpr 12
  或以 '-' 结尾, 这时剩下的全取为 '0'. <br>\
11219 bpr 13
  目前已实现的操作 `operation' 有以下几种.\
14
  <ul>\
15
   <li><tt>!text common `text1' and `text2'\
16
    [mask `maskstring']\
17228 bpr 17
 <br>\
11219 bpr 18
    把 `text1' 中与 `text2' 的对应字符相同,\
19
    又不被 `maskstring' 掩盖的字符一个一个地提取出来.\
20
   <li><tt>!text compare `text1' and `text2'\
21
    \
17228 bpr 22
 <br>\
11219 bpr 23
    对 `text1' 与 `text2' 的字符逐个比较,\
24
    返回一个掩码串, 其中两个串的对应字符相同的位置取 '0', 其它位置取 '1'.\
25
   <li><tt>!text copy `text'\
17228 bpr 26
    [mask `maskstring']</tt> <br>\
11219 bpr 27
    返回 `text' 内不被掩盖的字符.\
28
   <li><tt>!text count `charlist' in `text'\
17228 bpr 29
    [mask `maskstring']</tt> <br>\
11219 bpr 30
    返回 `text' 内既不被 `maskstring' 掩盖,\
31
    又包含在 `charlist' 里的字符的个数.\
32
   <li><tt>!text diff `text1' from `text2'\
17228 bpr 33
    [mask `maskstring']</tt> <br>\
11219 bpr 34
    把 `text1' 中与 `text2' 的对应字符不同,\
17228 bpr 35
    又不被 `maskstring' 掩盖的字符一个一个地提取出来. <br>\
11219 bpr 36
    (diff 的同义词: differ).\
37
   <li><tt>!text expand `text' using `maskstring'\
17228 bpr 38
    </tt> <br>\
11219 bpr 39
    生成这样的字符串: 与 `maskstring' 中的 '0' 对应的位置变为 ' '(空格),\
40
    与 `maskstring' 中的 '1' 对应的位置取为 `text'\
41
    中的字符, `text' 中的字符被一个一个地使用.\
42
    直至 `text' 的字符被用尽, 或生成的字符串达到长度限制才终止.\
43
   <li><tt>!text insert `text1' into `text2'\
17228 bpr 44
    [mask `maskstring']</tt> <br>\
11219 bpr 45
    把 `text2' 中未被掩盖的位置用 `text1' 的字符取代,\
46
    然后返回 `text2'. `text1' 的字符被一个一个地使用\
47
    (与掩码无关), 直至 `text1' 里没有字符时才结束.\
48
   <li><tt>!text interact `text1' and `text2'\
17228 bpr 49
    table `itab' [mask `maskstring']</tt> <br>\
11219 bpr 50
    返回一个新的文本, 它是 `text1' 与 `text2'\
17228 bpr 51
    的对应位置的字符相互作用的结果. 相互作用的规则由 `itab' 定义. <br>\
11219 bpr 52
    `itab' 有 n+1 行, 每行 n 个字符. 后面的 n\
53
    行字符定义了相对于第一行字符的乘法表.\
17228 bpr 54
    <br>\
11219 bpr 55
    乘法表不必对称. 这时的行对应于 `text1' 里的字符,\
56
    列则对应于 `text2' 里的字符.\
17228 bpr 57
    <br>\
11219 bpr 58
    如果 `text1' 或 `text2' 的对应字符中有一个不出现在\
59
    `itab' 的第一行, 则对应位置的相互作用结果是空(什么也没有).\
60
    类似地, 被掩盖的位置也被忽略.\
17228 bpr 61
    <br>\
11219 bpr 62
    如果 `text1' 与 `text2' 有不同长度,\
63
    就把长的串截短.\
64
   <li><tt>!text mark `charlist' in `text'\
17228 bpr 65
    </tt> <br>\
11219 bpr 66
    返回一个掩码串, 如果 `text' 的字符出现在 `charlist',\
67
    掩码串的相应位置取 '1', 否则取 '0'.\
68
   <li><tt>!text max `text1' and `text2'\
17228 bpr 69
    [mask `maskstring']</tt> <br>\
11219 bpr 70
    返回一个字符串, 其字符是 `text1' 与 `text2'\
71
    的对应字符中 ASCII 码较大的那个. 长度等于较长的串. 掩盖的位置被跳过.\
72
   <li><tt>!text min `text1' and `text2'\
17228 bpr 73
    [mask `maskstring']</tt> <br>\
11219 bpr 74
    返回一个字符串, 其字符是 `text1' 与 `text2'\
75
    的对应字符中 ASCII 码较小的那个. 长度等于较短的串. 掩盖的位置被跳过.\
76
   <li><tt>!text occur `charlist' in `text'\
17228 bpr 77
    [mask `maskstring']</tt> <br>\
11219 bpr 78
    返回 `charlist' 中出现在 `text'\
17228 bpr 79
    里未被掩盖位置的字符. <br>\
11219 bpr 80
    (occur 的同义词: appear, occurrence).\
81
   <li><tt>!text remove `charlist' in `text'\
17228 bpr 82
    [mask `maskstring']</tt> <br>\
11219 bpr 83
    返回字符串 `text', 其中除去了被掩盖的字符以及出现在\
17228 bpr 84
    `charlist' 里的字符. <br>\
11219 bpr 85
    (remove 的同义词: drop, delete).\
86
   <li><tt>!text reorder `text' by `orderlist'\
17228 bpr 87
    </tt> <br>\
11219 bpr 88
    返回利用排序表 `orderlist' 重排过的 `text'.\
17228 bpr 89
    当 `orderlist' 比 `text' 短时, 重排将循环进行. <br>\
11219 bpr 90
    `orderlist' 必须是集合 {1,...,n} 的排列表.\
91
    如果 `orderlist' 含有超界的整数, 返回的是空串.\
92
    但是对 `orderlist' 的项并不作唯一性检查.\
93
   <li><tt>!text repeat `text' to `len'\
17228 bpr 94
    </tt> <br>\
11219 bpr 95
    循环地重复串 `text', 直至达到长度 `len'.\
17228 bpr 96
   <li><tt>!text reverse `text'</tt> <br>\
11219 bpr 97
    颠倒 `text' 的次序.\
98
   <li><tt>!text select `charlist' in `text'\
17228 bpr 99
    [mask `maskstring']</tt> <br>\
11219 bpr 100
    返回字符串 `text', 其中除去了被掩盖的字符以及不出现在\
17228 bpr 101
    `charlist' 里的字符. <br>\
11219 bpr 102
    (select 的同义词: pick, pickup).\
2071 zjchen 103
  </ul>