项目

一般

简介

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

yangdefeng, 2021-11-03 22:11

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 25 yangdefeng
格式:
108
|命令名      |参数1   |参数2   |
109
|getStringPos|文件路径|查找内容|
110
111
112 1 yangdefeng
说明:
113 25 yangdefeng
返回值放在N0变量中,
114
如果N0=9999999说明没有找到.
115 1 yangdefeng
116 25 yangdefeng
bq. %{color:lightgrey}用例:%
117
#act
118
getStringPos ..\QuestDiary\测试.txt 管理员
119 1 yangdefeng
sendMsg 6 字符串在列表中的位置:<notextile><$STR(N0)></notextile>
120
121
----
122
123
h4. *_%{color:green}addTextListEx%_*
124
125
*字符串写入文件*
126
127
格式:
128
129
|_.命令名     |_.参数1|_.参数2 |_.参数3 |
130
|addTextListEx|路径   |写入文本|写入行号|
131
132
说明:
133
* 参数1:支持变量传值
134
* 参数2:支持变量传值
135
136
bq. 用例:
137
addTextListEx ..\QuestDiary\TestList.txt <$USERNAME> 0
138
139
140
*_%{color:green}addTextList%_*
141
格式:AddTextList ..\TestList.txt 您的名字
142
格式:AddTextList ..\TestList.txt 您的名字 您的性别
143
说明:无行号
144
145
----
146
147
h4. _%{color:green}delTextList%_
148
149
*删除文件中的字符串*
150
151
格式:DelTextList ..\TestList.txt 您的名字
152
格式:DelTextList ..\TestList.txt 您的名字 您的性别
153
154
----
155
156
h4. _%{color:green}inc%_
157
158
*字符串加法*
159
160
格式:
161 29 yangdefeng
inc 字符串变量 字符串
162 1 yangdefeng
163
说明:
164 29 yangdefeng
原字符串变量的值追加新字符串内容
165
166
bq. %{color:lightgrey}用例;%
167
#act
168
mov s$我的字符串 一二三
169
inc s$我的字符串 四五六
170
sendMsg 6 <$str(s$我的字符串)>
171 1 yangdefeng
172
----
173
174
h4. _%{color:green}dec%_
175
176
*字符串减法*
177
178
格式:
179
dec 字符串1 字符串2
180
181
说明:
182
183
----
184
185
h4. _%{color:green}compareText%_
186
187
*字符串比对*
188
189
格式:
190
CompareText 字符串1 字符串2
191
192
说明:
193
194
例子:
195
CompareText <$KILLMONNAME> 宝藏守卫者
196
197
----
198
199
h4. _*%{color:green}setStringBlank%*_
200
201
格式:
202
203
|命令名        |参数1|参数2|参数3|
204
|setStringBlank|变量 |长度 |前后 |
205
206
说明:
207
208
* 参数1:变量支持A与S
209
* 参数2:设定变量固定长度
210
** 单个字母1个长度
211
** 单个汉字2个长度
212
* 参数3:前置或后置补空格
213
** 0,前置
214
** 1,后置
215
216 27 yangdefeng
bq. %{color:lightgrey}用例:
217
;字符串原长度13(中文占两位)
218
;给字符串前面补7个空格%
219 28 yangdefeng
#act
220 1 yangdefeng
mov S10 gameofmir引擎
221 26 yangdefeng
<notextile>setStringBlank <$STR(S10)> 20 0</notextile>
222 27 yangdefeng
223 1 yangdefeng
224
----
225
226 2 yangdefeng
h3. 字符串随机
227
228 8 yangdefeng
h4. _%{color:green}getRandomText%_
229
230
*从文件中随机获取一行字符串*
231
232
格式: 
233
GetRandomText 文件路径 变量(S0--S99) 指定行(0-10000)
234
235
说明: 
236 9 yangdefeng
未指定行时,随机取某一行的字符串.
237 8 yangdefeng
238
----
239
240 2 yangdefeng
h4. _%{color:green}getRandomLineText%_
241 6 yangdefeng
242
*从文件中随机取文本*
243
244 1 yangdefeng
格式:
245
246 8 yangdefeng
|命令名           |参数1|参数2|
247
|getRandomLineText|路径 |变量 |
248 1 yangdefeng
249
250 8 yangdefeng
说明:
251 6 yangdefeng
252 10 yangdefeng
bq. %{color:lightgrey}用例1:从文件..\QuestDiary\配置文件\1一大陆武器.txt中随机取值%
253
#act
254 1 yangdefeng
mov S$tmp 1一大陆武器
255
<notextile>getRandomLineText ..\QuestDiary\配置文件\<$STR(S$tmp)>.txt S$武器</notextile>
256 10 yangdefeng
%{color:lightgrey}用例2:%
257
#act
258 8 yangdefeng
getRandomLineText ..\QuestDiary\装备列表.txt S0
259 6 yangdefeng
260
----
261 2 yangdefeng
262 1 yangdefeng
h3. 字符串检测
263 12 yangdefeng
264
h4. _%{color:green}checkStringlength%_
265
266
*检测字符串长度*
267
268
格式:
269
checkStringlength 字符串 操作符(<,>,=) 位数
270
271
说明:一个汉字位数为2
272
273
bq. 用例:
274
[@test]
275
#IF
276 14 yangdefeng
checkStringlength D3dm2 > 3
277
#act
278
sendMsg 6 D3dm2大于3个字符
279 1 yangdefeng
#ELSESAY
280 14 yangdefeng
sendMsg 6 D3dm2小于3个字符
281
282
----
283
284
h4. _%{color:green}checkTextList%_
285
286
*检查字符串是否在指定文件中*
287
288
格式:
289
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)></notextile>
290
291
说明:
292
293
格式:
294
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)> <$STR(S$3)></notextile>
295
296
说明:
297
S$2和S$3的值在“10元卡号.txt”文本中以空格分开
298 12 yangdefeng
299
----
300 16 yangdefeng
301
h4. _*%{color:green}checkContainsText%*_
302
303
*检查字符串A是否包涵字符串B*
304
305
格式:
306
checkContainsText 字符串A 字符串B
307
308
说明:
309
310
bq. 用例:
311
#if
312
<notextile>checkContainsText www.gameofmir.com gameofmir.com</notextile>
313
#act
314
sendMsg 6 包涵
315
#elseAct
316
sendMsg 6 不包涵
317
318
----