项目

一般

简介

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

yangdefeng, 2021-11-13 14:08

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 30 yangdefeng
*格式:*
179
|命令名|参数1|参数2       |
180
|dec   |变量 |字符串或数字|
181 1 yangdefeng
182 30 yangdefeng
*说明:*
183
* 参数1:需要处理的字符串变量
184
* 参数2
185
** 参数2为字符串,则参数1字符串变量中删除参数2对应的内容,并保存参数1字符串变量
186
** 参数2为数值,则选择参数1字符串变量中[前参数2]个字符,保存至参数1字符串变量 
187
188
*用例:*
189
190
bq. #act
191
mov S1 tejie引擎M2
192
%{color:lightgrey};删除S1中的“引擎M2”字符串%
193
dec S1 引擎M2
194
195
196
bq. #act
197
mov S1 tejie引擎M2
198
%{color:lightgrey};保留S1的前7个字符%
199
dec S1 7
200 1 yangdefeng
201
----
202
203
h4. _%{color:green}compareText%_
204
205
*字符串比对*
206
207
格式:
208
CompareText 字符串1 字符串2
209
210
说明:
211
212
例子:
213
CompareText <$KILLMONNAME> 宝藏守卫者
214
215
----
216
217
h4. _*%{color:green}setStringBlank%*_
218
219
格式:
220
221
|命令名        |参数1|参数2|参数3|
222
|setStringBlank|变量 |长度 |前后 |
223
224
说明:
225
226
* 参数1:变量支持A与S
227
* 参数2:设定变量固定长度
228
** 单个字母1个长度
229
** 单个汉字2个长度
230
* 参数3:前置或后置补空格
231
** 0,前置
232
** 1,后置
233
234 27 yangdefeng
bq. %{color:lightgrey}用例:
235
;字符串原长度13(中文占两位)
236
;给字符串前面补7个空格%
237 28 yangdefeng
#act
238 1 yangdefeng
mov S10 gameofmir引擎
239 26 yangdefeng
<notextile>setStringBlank <$STR(S10)> 20 0</notextile>
240 27 yangdefeng
241 1 yangdefeng
242
----
243
244 2 yangdefeng
h3. 字符串随机
245
246 8 yangdefeng
h4. _%{color:green}getRandomText%_
247
248
*从文件中随机获取一行字符串*
249
250
格式: 
251
GetRandomText 文件路径 变量(S0--S99) 指定行(0-10000)
252
253
说明: 
254 9 yangdefeng
未指定行时,随机取某一行的字符串.
255 8 yangdefeng
256
----
257
258 2 yangdefeng
h4. _%{color:green}getRandomLineText%_
259 6 yangdefeng
260
*从文件中随机取文本*
261
262 1 yangdefeng
格式:
263
264 8 yangdefeng
|命令名           |参数1|参数2|
265
|getRandomLineText|路径 |变量 |
266 1 yangdefeng
267
268 8 yangdefeng
说明:
269 6 yangdefeng
270 10 yangdefeng
bq. %{color:lightgrey}用例1:从文件..\QuestDiary\配置文件\1一大陆武器.txt中随机取值%
271
#act
272 1 yangdefeng
mov S$tmp 1一大陆武器
273
<notextile>getRandomLineText ..\QuestDiary\配置文件\<$STR(S$tmp)>.txt S$武器</notextile>
274 10 yangdefeng
%{color:lightgrey}用例2:%
275
#act
276 8 yangdefeng
getRandomLineText ..\QuestDiary\装备列表.txt S0
277 6 yangdefeng
278
----
279 2 yangdefeng
280 1 yangdefeng
h3. 字符串检测
281 12 yangdefeng
282
h4. _%{color:green}checkStringlength%_
283
284
*检测字符串长度*
285
286
格式:
287
checkStringlength 字符串 操作符(<,>,=) 位数
288
289
说明:一个汉字位数为2
290
291
bq. 用例:
292
[@test]
293
#IF
294 14 yangdefeng
checkStringlength D3dm2 > 3
295
#act
296
sendMsg 6 D3dm2大于3个字符
297 1 yangdefeng
#ELSESAY
298 14 yangdefeng
sendMsg 6 D3dm2小于3个字符
299
300
----
301
302
h4. _%{color:green}checkTextList%_
303
304
*检查字符串是否在指定文件中*
305
306
格式:
307
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)></notextile>
308
309
说明:
310
311
格式:
312
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)> <$STR(S$3)></notextile>
313
314
说明:
315
S$2和S$3的值在“10元卡号.txt”文本中以空格分开
316 12 yangdefeng
317
----
318 16 yangdefeng
319
h4. _*%{color:green}checkContainsText%*_
320
321
*检查字符串A是否包涵字符串B*
322
323
格式:
324
checkContainsText 字符串A 字符串B
325
326
说明:
327
328
bq. 用例:
329
#if
330
<notextile>checkContainsText www.gameofmir.com gameofmir.com</notextile>
331
#act
332
sendMsg 6 包涵
333
#elseAct
334
sendMsg 6 不包涵
335
336
----