项目

一般

简介

字符串 » 历史记录 » 版本 24

yangdefeng, 2021-11-03 21:46

1 1 yangdefeng
{{toc}}
2
3
h3. 字符串
4
5 18 yangdefeng
h4. _%{color:green}getListString%_
6
7
*读取文本中指定行的内容*
8
9 20 yangdefeng
*格式:*
10 19 yangdefeng
|命令名       |参数1   |参数2|参数3|
11
|getListString|文件路径|行号 |变量 |
12 1 yangdefeng
13 20 yangdefeng
*说明:*
14
读取文本文件指定行的内容,存入指定变量
15
16
bq. %{color:lightgrey}用例:%
17
#act
18 1 yangdefeng
getListString ..\QuestDiary\NewFile.txt 0 <notextile>S$tmp</notextile>
19
20 20 yangdefeng
21 18 yangdefeng
22
----
23
24 1 yangdefeng
h4. *_%{color:green}pgExtractString%_*
25
26
字符串分割
27
28
格式:
29
30
|命令名         |参数1 |参数2   |参数3 |参数4 |
31
|pgExtractString|分割符|分割对象|变量名|变量名|
32
33
说明:
34
* 参数1:自定义的分割符
35
* 参数2:待分割的字符串
36
* 参数3:存放分割结果的变量列表,变量名_1、变量名_2、依次类推
37
* 参数4:存放分割数量
38
39
bq. %{color:lightgrey};用例1:%
40
[@main]
41
#if
42
#act
43
pgExtractString | 测试文本1|测试文本2 S$测试变量 N0
44
<notextile>sendMsg 6 你将文本分割了,并将分割后的内容保存在变量【S$测试变量_1】和【S$测试变量_2】中,他们的值分别是<$STR(S$测试变量_1)>和<$STR(S$测试变量_2)>,分割后共获得了【<$STR(N0)>】个内容</notextile>
45
%{color:lightgrey};--%
46
%{color:lightgrey};用例:2%
47
[@main]
48
#act
49
mov N$幸运等级 <$str(U1017)>
50
dec N$幸运等级 1
51
%{color:lightgrey};读取文件指定行%
52
getListString ..\QuestDiary\幸运项链\数据表.txt <$str(N$幸运等级)> S$返回串
53
%{color:lightgrey};对字符串分割取值%
54
pgExtractString | S$返回串 S$返回值 N$分割数
55
<notextile>mov N$幸运倍攻加成 <$STR(S$返回值_6)></notextile>
56
57
----
58
59
h4. *_%{color:green}extractString%_*
60
61
格式:
62 23 yangdefeng
|命令名       |参数1 |参数2       |参数3|参数4|参数5|参数6|参数7|参数8|参数9|参数10|
63
|extractString|分割符|待分割字符串|变量1|变量2|变量3|变量4|变量5|变量6|变量7|变量8 |
64
65 1 yangdefeng
说明:
66 23 yangdefeng
按照指定分割符分割字符串,并存入多个变量中
67 1 yangdefeng
68 23 yangdefeng
bq. %{color:lightgrey}用例:%
69 1 yangdefeng
#act
70
mov S0 战神盔甲(男):裁决之杖:绿色项链:黑铁头盔:骑士手镯:骑士手镯:力量戒指:力量戒指
71
<notextile>extractString : <$STR(S0)> s1 s2 s3 s4 s5 s6 s7 s8</notextile>
72
<notextile>sendmsg 6 分割结果:<$STR(S1)> <$STR(S2)> <$STR(S3)> <$STR(S4)> <$STR(S5)> <$STR(S6)> <$STR(S7)> <$STR(S8)></notextile>
73
74
----
75
76
h4. _*%{color:green}ansiReplaceText%*_
77
78
字符串替换
79
80
格式:
81
82
|命令名         |参数1      |参数2   |参数3  |
83
|ANSIREPLACETEXT|字符串变量 |旧字符串| 新字符|
84
85
说明:
86
87 24 yangdefeng
* 参数1:待处理的字符串
88
* 参数2:待处理的字符串中需要换掉的内容
89
* 参数3:待处理的字符串中需要换入的内容
90 1 yangdefeng
91 22 yangdefeng
bq. %{color:lightgrey}用例:
92
;把www.top166.com替换成 qq.com
93
%
94
[@main]
95
#if 
96
#act
97
mov S0 <notextile>www.top166.com</notextile>
98
ansiReplaceText S0 <notextile>www.top166</notextile> qq
99
sendmsg 6 <notextile><$STR(S0)></notextile>
100
101 1 yangdefeng
----
102
103
h4. *_%{color:green}getStringPos%_*
104
105 21 yangdefeng
*取字符串在列表中的位置(下标)*
106 1 yangdefeng
107
格式:getStringPos ..\QuestDiary\测试.txt 管理员
108
说明:
109
110
sendMsg 6 字符串在列表中的位置:<notextile><$STR(N0)></notextile>
111
112
----
113
114
h4. *_%{color:green}addTextListEx%_*
115
116
*字符串写入文件*
117
118
格式:
119
120
|_.命令名     |_.参数1|_.参数2 |_.参数3 |
121
|addTextListEx|路径   |写入文本|写入行号|
122
123
说明:
124
* 参数1:支持变量传值
125
* 参数2:支持变量传值
126
127
bq. 用例:
128
addTextListEx ..\QuestDiary\TestList.txt <$USERNAME> 0
129
130
131
*_%{color:green}addTextList%_*
132
格式:AddTextList ..\TestList.txt 您的名字
133
格式:AddTextList ..\TestList.txt 您的名字 您的性别
134
说明:无行号
135
136
----
137
138
h4. _%{color:green}delTextList%_
139
140
*删除文件中的字符串*
141
142
格式:DelTextList ..\TestList.txt 您的名字
143
格式:DelTextList ..\TestList.txt 您的名字 您的性别
144
145
----
146
147
h4. _%{color:green}inc%_
148
149
*字符串加法*
150
151
格式:
152
inc 字符串1 字符串2
153
154
说明:
155
156
----
157
158
h4. _%{color:green}dec%_
159
160
*字符串减法*
161
162
格式:
163
dec 字符串1 字符串2
164
165
说明:
166
167
----
168
169
h4. _%{color:green}compareText%_
170
171
*字符串比对*
172
173
格式:
174
CompareText 字符串1 字符串2
175
176
说明:
177
178
例子:
179
CompareText <$KILLMONNAME> 宝藏守卫者
180
181
----
182
183
h4. _*%{color:green}setStringBlank%*_
184
185
格式:
186
187
|命令名        |参数1|参数2|参数3|
188
|setStringBlank|变量 |长度 |前后 |
189
190
说明:
191
192
* 参数1:变量支持A与S
193
* 参数2:设定变量固定长度
194
** 单个字母1个长度
195
** 单个汉字2个长度
196
* 参数3:前置或后置补空格
197
** 0,前置
198
** 1,后置
199
200
bq. 用例:
201
mov S10 gameofmir引擎
202
<notextile>setStringBlank <$STR(S10)> 20 0</notextile>
203
;字符串原长度13
204
;给字符串前面补7个空格
205
206
----
207
208 2 yangdefeng
h3. 字符串随机
209
210 8 yangdefeng
h4. _%{color:green}getRandomText%_
211
212
*从文件中随机获取一行字符串*
213
214
格式: 
215
GetRandomText 文件路径 变量(S0--S99) 指定行(0-10000)
216
217
说明: 
218 9 yangdefeng
未指定行时,随机取某一行的字符串.
219 8 yangdefeng
220
----
221
222 2 yangdefeng
h4. _%{color:green}getRandomLineText%_
223 6 yangdefeng
224
*从文件中随机取文本*
225
226 1 yangdefeng
格式:
227
228 8 yangdefeng
|命令名           |参数1|参数2|
229
|getRandomLineText|路径 |变量 |
230 1 yangdefeng
231
232 8 yangdefeng
说明:
233 6 yangdefeng
234 10 yangdefeng
bq. %{color:lightgrey}用例1:从文件..\QuestDiary\配置文件\1一大陆武器.txt中随机取值%
235
#act
236 1 yangdefeng
mov S$tmp 1一大陆武器
237
<notextile>getRandomLineText ..\QuestDiary\配置文件\<$STR(S$tmp)>.txt S$武器</notextile>
238 10 yangdefeng
%{color:lightgrey}用例2:%
239
#act
240 8 yangdefeng
getRandomLineText ..\QuestDiary\装备列表.txt S0
241 6 yangdefeng
242
----
243 2 yangdefeng
244 1 yangdefeng
h3. 字符串检测
245 12 yangdefeng
246
h4. _%{color:green}checkStringlength%_
247
248
*检测字符串长度*
249
250
格式:
251
checkStringlength 字符串 操作符(<,>,=) 位数
252
253
说明:一个汉字位数为2
254
255
bq. 用例:
256
[@test]
257
#IF
258 14 yangdefeng
checkStringlength D3dm2 > 3
259
#act
260
sendMsg 6 D3dm2大于3个字符
261 1 yangdefeng
#ELSESAY
262 14 yangdefeng
sendMsg 6 D3dm2小于3个字符
263
264
----
265
266
h4. _%{color:green}checkTextList%_
267
268
*检查字符串是否在指定文件中*
269
270
格式:
271
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)></notextile>
272
273
说明:
274
275
格式:
276
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)> <$STR(S$3)></notextile>
277
278
说明:
279
S$2和S$3的值在“10元卡号.txt”文本中以空格分开
280 12 yangdefeng
281
----
282 16 yangdefeng
283
h4. _*%{color:green}checkContainsText%*_
284
285
*检查字符串A是否包涵字符串B*
286
287
格式:
288
checkContainsText 字符串A 字符串B
289
290
说明:
291
292
bq. 用例:
293
#if
294
<notextile>checkContainsText www.gameofmir.com gameofmir.com</notextile>
295
#act
296
sendMsg 6 包涵
297
#elseAct
298
sendMsg 6 不包涵
299
300
----