如何使用 VS Find/Replace 进行替换:
这: $('a[name="lnkFind"]').on('click', 函数
用这个: $(document).on("click", "a[name='lnkFind']", function
我不确定哪些字符需要转义 - 单引号或双引号或两者兼而有之?我尝试过的所有模式似乎都找不到匹配项。
如何使用 VS Find/Replace 进行替换:
这: $('a[name="lnkFind"]').on('click', 函数
用这个: $(document).on("click", "a[name='lnkFind']", function
我不确定哪些字符需要转义 - 单引号或双引号或两者兼而有之?我尝试过的所有模式似乎都找不到匹配项。
您需要转义许多这些字符。
Find/Replace 会抱怨未转义的(
and )
,甚至是最后的裸露(
,因为它缺少匹配的)
. 还有方括号,用于字符集,最后是$
.
所以这应该作为模式工作:
\$\('a\[name="lnkFind"\]'\).on\('click', function
Except in special cases (such as vim regex), in general you can escape any and all special characters in regex to get their literal form, i.e. escaping a special character that doesn't need to be escaped, won't do any harm.
That said, here's the minimum that needs to be escaped:
\$\('a\[name="lnkFind"]')\.on\('click', function
I don't think you'll need to escape anything in the replacement, because only a $
or \
followed by a number will be interpreted.
您应该查看正则表达式中的特殊字符列表。
$
, .
, [
,]
都应该被转义。
http://www.fon.hum.uva.nl/praat/manual/Regular_expressions_1__Special_characters.html