[英]Match Escaped Dollar Sign in literal but not variable
I'm trying to determine if a value matches a string input by the user. 我试图确定一个值是否与用户输入的字符串匹配。 When trying to match a dollar sign, I take the input string and replace the dollar sign with an escaped dollar sign ("\\\\$").
当尝试匹配美元符号时,我将输入字符串并用转义的美元符号(“ \\\\ $”)替换美元符号。 However, this doesn't match, but it will match if instead of assigning this value to a variable I just use the literal string.
但是,这不匹配,但是如果不是将这个值分配给变量,而只是使用文字字符串,它将与之匹配。 Here's a console snapshot illustrating this:
这是一个控制台快照,说明了这一点:
why is this happening?? 为什么会这样?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.