[英]Copy date from one line to multiple lines (Regex Notepad++)
I've been using Notepad++ for a while now but I haven't been able to figure this one out so any help is appreciated. 我已经使用Notepad ++一段时间了,但是我无法弄清楚这一点,因此感谢您的帮助。 I have this: 我有这个:
Day:2016-08-06 一天:2016-08-06
DATE/1850_01.xlsx DATE / 1850_01.xlsx
DATE/1850_02.xlsx DATE / 1850_02.xlsx
DATE/1850_03.xlsx DATE / 1850_03.xlsx
DATE/1850_04.xlsx DATE / 1850_04.xlsx
DATE/1850_05.xlsx DATE / 1850_05.xlsx
DATE/1850_06.xlsx 日期DATE / 1850_06.xlsx
DATE/1850_07.xlsx DATE / 1850_07.xlsx
DATE/1850_08.xlsx DATE / 1850_08.xlsx
And I need a regex that takes the date in "Day:" (which here is 2016-08-06 but it varies, may be another random date like 2016-04-23 and so on) and replaces it on all of the "DATE". 而且我需要一个正则表达式,该日期必须以“ Day:”作为日期(此处为2016-08-06,但可能有所不同,可能是另一个随机日期,例如2016-04-23,依此类推),然后将其替换为所有“日期”。 Basically this: 基本上是这样的:
Day:2016-08-06 一天:2016-08-06
2016-08-06/1850_01.xlsx 2016-08-06 / 1850_01.xlsx
2016-08-06/1850_02.xlsx 2016-08-06 / 1850_02.xlsx
2016-08-06/1850_03.xlsx 2016-08-06 / 1850_03.xlsx
2016-08-06/1850_04.xlsx 2016-08-06 / 1850_04.xlsx
2016-08-06/1850_05.xlsx 2016-08-06 / 1850_05.xlsx
2016-08-06/1850_06.xlsx 2016-08-06 / 1850_06.xlsx
2016-08-06/1850_07.xlsx 2016-08-06 / 1850_07.xlsx
2016-08-06/1850_08.xlsx 2016-08-06 / 1850_08.xlsx
Here is aa regular expression find/replace approach: 这是一个正则表达式查找/替换方法:
(Day:([^[:space:]]+).*?)DATE
查找内容:( (Day:([^[:space:]]+).*?)DATE
\\1\\2
替换为: \\1\\2
. mathces newline
检查. mathces newline
. mathces newline
This will replace the first occurence. 这将代替第一次出现。 You have to repeat Replace
until all replacements are done (Replace All does not make a difference due to the nature of the RE). 您必须重复“ Replace
直到完成所有Replace
为止(由于RE的性质,“全部替换”不起作用)。 You can keep Alt-R pressed in the replace dialog, it is fast. 您可以在替换对话框中按住Alt-R,速度很快。
But there is another approach: Mark the date, copy it into clipboard, use a normal Replace, to replace DATE
with the copied date from the first line, here Replace all will work. 但是还有另一种方法:标记日期,将其复制到剪贴板中,使用常规的替换,用第一行中复制的日期替换DATE
,这里全部替换将起作用。 Its about the same keypresses and it is more straight forward. 其大约相同的按键,并且更加简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.