项目

一般

简介

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

yangdefeng, 2021-11-03 21:50

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