如何使用Notepad ++在引号中包裹单词?

时间:2019-05-04 09:33:14

标签: notepad++

具体来说,如果可能的话,我想将许多单词包装在自己的引号中。我知道之前已经有人问过这个问题,但坦白说,由于我不是N ++的编码人员或常规用户,所以我不明白答案。因此,如果可以像我2岁那样来解释它,那将不胜感激。

1 个答案:

答案 0 :(得分:1)

  • Ctrl + H
  • 查找内容:(?<!")\b\w+\b(?!")
  • 替换为:"$0"
  • 检查环绕
  • 检查正则表达式
  • 全部替换

说明:

(?<!")          # negative lookbehind, make sure we haven't quote before the word
\b              # word boundary
\w+             # 1 or more word character
\b              # word boundary
(?!")           # negative lookahead, make sure we haven't quote after the word

替换:

"       # a double quote
$0      # the whole match (i.e. the word)
"       # a double quote

给出:

 Tony, Paul, Eric, Sarah, "Tony", "Paul", "Eric", "Sarah"

给定示例的结果

 "Tony", "Paul", "Eric", "Sarah", "Tony", "Paul", "Eric", "Sarah"