在Notepad ++中搜索/替换块选择

时间:2015-04-20 22:00:48

标签: replace notepad++ block selection

有没有办法将搜索/替换仅限于Notepad ++中的柱状块选择?

以下是我要做的事情:

  • 我正在批量编辑从大量照片中提取的元数据。

  • 元数据作为csv文件发送给我,在标题行中的字段周围没有引号,并且在每个后续行的第一个字段周围没有引号。

  • 我在Open Office calc中编辑此文件,该文件使用所有字段的引号导出。

  • 我可以轻松编辑标题行,但问题在于从连续行中的第一个字段中删除引号。

  • 我可以在柱状模式下使用记事本,但在选择第一列后,仅在选择中搜索'选项框显示为灰色。

  • 我可以手工完成,但这意味着大量的手工操作和错误的机会增加。

5 个答案:

答案 0 :(得分:1)

我知道,这可能不会对你有任何帮助,但我遇到了同样的问题并偶然发现了这个问题。

我发现将有问题的块移动到一个新文件并执行查找/替换它的工作相当不错。向后移动块时,请务必在块模式下选择它(参见this question)。

答案 1 :(得分:0)

没有。另一位编辑可能有此功能。

答案 2 :(得分:0)

一种迟到的回复但是......当我搬到安装了Notepad ++的新机器时,我遇到了同样的问题。以前,我使用的是一个名为Boxer的文本编辑器,它具有此功能,我发现它非常宝贵。然而,它不是免费的。

答案 3 :(得分:0)

您可能无法在列式选择中搜索/替换,但您可以在Notepad ++中轻松执行任务。使用“查找和替换”功能,使用正则表达式选中

如果您只想从目标列中删除引号,请在查找字段中使用以下正则表达式:

 (^([^,]*,){i})"([^,\n\r]*)"(.*$)

i 替换为目标列的位置减去1。

(例如,如果您想要第三列的引号,第一列的0等,请使用我们2)

替换字段中使用:

 \1\3\4

点击"全部替换"将从目标列中删除引号。

如果您想在没有偏见的情况下吹走csv中每个元素周围的所有引号,请在查找字段中使用以下正则表达式:

 ((?<=,)|(?<=^))"(.*?)"((?=$|,))

替换字段中使用:

 \1\2\3

点击全部替换将从列中删除引号。

实施例

由于您没有提供示例csv文件,因此我将介绍我自己的工作示例。以下是我的csv:

 "0","1","2","3","4","5","6","7","8","9"
 "10","11","12","13","14","15","16","17","18","19"
 "20","21","22","23","24","25","26","27","28","29"
 "30","31","32","33","34","35","36","37","38","39"
 "40","41","42","43","44","45","46","47","48","49"
 "50","51","52","53","54","55","56","57","58","59"
 "60","61","62","63","64","65","66","67","68","69"
 "70","71","72","73","74","75","76","77","78","79"
 "80","81","82","83","84","85","86","87","88","89"
 "90","91","92","93","94","95","96","97","98","99"
 "100","101","102","103","104","105","106","107","108","109"
 "110","111","112","113","114","115","116","117","118","119"
 "120","121","122","123","124","125","126","127","128","129"
 "130","131","132","133","134","135","136","137","138","139"
 "140","141","142","143","144","145","146","147","148","149"
 "150","151","152","153","154","155","156","157","158","159"
 "160","161","162","163","164","165","166","167","168","169"
 "170","171","172","173","174","175","176","177","178","179"
 "180","181","182","183","184","185","186","187","188","189"
 "190","191","192","193","194","195","196","197","198","199"

如果我想删除第二列中的引号,我会使用以下查找替换字段

 (^([^,]*,){1})"([^,\n\r]*)"(.*$)

 \1"\3"\4

点击全部替换会产生以下结果:

 "0",1,"2","3","4","5","6","7","8","9"
 "10",11,"12","13","14","15","16","17","18","19"
 "20",21,"22","23","24","25","26","27","28","29"
 "30",31,"32","33","34","35","36","37","38","39"
 "40",41,"42","43","44","45","46","47","48","49"
 "50",51,"52","53","54","55","56","57","58","59"
 "60",61,"62","63","64","65","66","67","68","69"
 "70",71,"72","73","74","75","76","77","78","79"
 "80",81,"82","83","84","85","86","87","88","89"
 "90",91,"92","93","94","95","96","97","98","99"
 "100",101,"102","103","104","105","106","107","108","109"
 "110",111,"112","113","114","115","116","117","118","119"
 "120",121,"122","123","124","125","126","127","128","129"
 "130",131,"132","133","134","135","136","137","138","139"
 "140",141,"142","143","144","145","146","147","148","149"
 "150",151,"152","153","154","155","156","157","158","159"
 "160",161,"162","163","164","165","166","167","168","169"
 "170",171,"172","173","174","175","176","177","178","179"
 "180",181,"182","183","184","185","186","187","188","189"
 "190",191,"192","193","194","195","196","197","198","199"

答案 4 :(得分:0)

我在互联网上搜索以查看天气记事本++的情况使此事受阻;带我到这。 我已经使用了TextPad,并确认它在列选择的块内支持查找和替换。此外,TextPad可供个人免费使用。