Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我在 NotePad++ 中的 Find 有一个正则表达式:
request\.POST\["[a-z A-Z _]*"\]
它正确地找到了我需要的东西。我想做的是使用我在替换中找到的部分内容。在我的替换中,我想使用括号之间的部分:
"[a-z A-Z _]*"
我该怎么做?谢谢!
编辑:
对于任何想知道的人,这就是我最终放入“替换”字段的内容:
$1 = request\.POST\["$1"\]
这也行得通:
\1 = request\.POST\["\1"\]
在您的查找中将其括在括号中。
request\.POST\[("[a-z A-Z _]*")\]
然后\1在您的替换中使用。这将返回第一组括号捕获的内容。(如果您有多个捕获组,请使用\2,\3等。
\1
\2
\3