Subversion Repositories wimsdev

Rev

Rev 4563 | Rev 11219 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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