批量引用相等性测试
如何测试我的字符串是否是引号 (")。 默认转义字符是“^”,不是吗?
所以我尝试了以下方法,但尚未成功:
if "!first_char!" == "^"" (...)
我也尝试了双引号:
if "!first_char!" == """" (...)
谢谢!
How can I test my string as if it is a quote (") or not.
The default escape character is '^', isn't it?
So I tried the following but with no success yet:
if "!first_char!" == "^"" (...)
I tried double quote, too:
if "!first_char!" == """" (...)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题不在于比较的右侧部分,而在于左侧部分。由于first_char包含引号,因此比较的左操作数没有意义。所以你必须用
^
转义保存"
的变量。尝试这样的事情......
The problem is not with the right part of the comparison, but with the left part. As first_char contains a quote, then the left operand of the comparison does not make sense. So you have to escape with
^
the variable that holds the"
.try something like this...
问题仅出在比较的右侧部分。
左侧的延迟扩张始终是安全的。
因此,您也可以简单地在右侧使用延迟扩展,例如
或者您可以转义所有引号。
The problem is only on the right part of the comparision.
The delayed expansion on the left side is always safe.
So you could simply use also a delayed expansion on the right side, like
Or alternativly you could escape all quotes.