此StringReplace代码有什么问题? [英] What is wrong with this StringReplace code?

查看:78
本文介绍了此StringReplace代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个字符串XXX:ABC.我想删除XXX:,使字符串变为ABC.

I have this string XXX:ABC. I want to remove XXX: so that the string becomes ABC .

变量Symbol包含字符串XXX:ABC.

代码如下:

MsgBox, Symbol %Symbol%
SearchText := "XXX:"
ReplaceText := ""
StringReplace, newSymbol, Symbol, SearchText, ReplaceText, ALL 
MsgBox, newSymbol %newSymbol%

在消息框输出中,newSymbol的内容与Symbol相同.有人可以告诉我我的代码有什么问题吗?

From the message box output, newSymbol content is the same as Symbol. Can someone tell me what is wrong with my code?

我正在使用Autohotkey v1.1.14.03.

I am using Autohotkey v1.1.14.03.

推荐答案

对于命令参数,您必须区分变量参数值参数. 例如,StringReplace具有以下参数列表:

For command parameters, you have to distinguish between variable parameters and value parameters. StringReplace for instance has the following argument list:

StringReplace, OutputVar InputVar ,SearchText [,ReplaceText, ReplaceAll?]

StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]

文档进一步说:

OutputVar:要在其中存储结果的变量的名称 更换过程.

OutputVar: The name of the variable in which to store the result of the replacement process.

InputVar:将读取其内容的变量的名称 来自.

InputVar: The name of the variable whose contents will be read from.

SearchText:要搜索的字符串.

SearchText: The string to search for.

如您所见,某些参数应该是变量名称,而其他参数应该是,例如字符串或数字.通过将变量内容括在百分号中或在表达式中使用它们,可以将变量内容用作值参数:

As you can see, some parameters are expected to be variable names, whereas others are expected to be values like strings or numbers. You can use variable contents as value parameters by either enclosing them in percent signs or using them within an expression:

StringReplace, newSymbol, Symbol, %SearchText%, %ReplaceText%, ALL
; or as an expression
StringReplace, newSymbol, Symbol, % SearchText, % ReplaceText, ALL

这篇关于此StringReplace代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆