Regex aying表示,无论是正则表达式(与生俱来)还是记事本++使用该正则表达式实现搜索和替换,都不支持替换的数学方法。尽管正则表达式被提及(并标记)为一种可能的方法,OP似乎不太关心特定的方法,而只是知道Notepad++是否可以完成任务……voithos的答

Regex aying表示,无论是正则表达式(与生俱来)还是记事本++使用该正则表达式实现搜索和替换,都不支持替换的数学方法。尽管正则表达式被提及(并标记)为一种可能的方法,OP似乎不太关心特定的方法,而只是知道Notepad++是否可以完成任务……voithos的答,regex,notepad++,sequential,Regex,Notepad++,Sequential,aying表示,无论是正则表达式(与生俱来)还是记事本++使用该正则表达式实现搜索和替换,都不支持替换的数学方法。尽管正则表达式被提及(并标记)为一种可能的方法,OP似乎不太关心特定的方法,而只是知道Notepad++是否可以完成任务……voithos的答案完美地解决了这一问题。+1表示晦涩难懂的专栏功能,并指出vim是一个更强大的编辑器。;)记事本++很棒,如果我们有一个像这个一样强大的在线文本编辑器那就太好了。对我来说是:用Alt+Shift选择列,然后做数字插入。工作完美谢谢!这个功能很棒


aying表示,无论是正则表达式(与生俱来)还是记事本++使用该正则表达式实现搜索和替换,都不支持替换的数学方法。尽管正则表达式被提及(并标记)为一种可能的方法,OP似乎不太关心特定的方法,而只是知道Notepad++是否可以完成任务……voithos的答案完美地解决了这一问题。+1表示晦涩难懂的专栏功能,并指出vim是一个更强大的编辑器。;)记事本++很棒,如果我们有一个像这个一样强大的在线文本编辑器那就太好了。对我来说是:用Alt+Shift选择列,然后做数字插入。工作完美谢谢!这个功能很棒。此外,我还可以通过双击来选择专栏。太棒了!刚刚在准备300条插入语句的时候救了我的命,我想如果我真的注意的话会有所帮助。最终安装了升华文本。:)谢谢。但一定要按“全部替换”按钮。“替换下一个”不会增加计数器。花了好几个小时才弄明白\我替换为从1开始,递增1的数字\i(10)替换为从10开始,递增1的数字\i(0,10)替换为从0开始,递增10的数字\i(100,-10)替换为从100开始的数字,递减为-10。如果您在帖子中附上图像,以避免在没有
的情况下在正则表达式模式下阅读您的回答时混淆,则会更好。匹配新行
将为您提供100%的解决方案。
<row id="1" />
<row id="1" />
<row id="1" />
<row id="1" />
<row id="1" />
<row id="1" />
<row id="2" />
<row id="3" />
<row id="4" />
<row id="5" />
1
2
3
4
5
1" />
<row id="2" />
<row id="3" />
<row id="4" />
<row id="5
|   <row id="   |   1   |   " />    |
|   <row id="   |   1   |   " />    |
|   <row id="   |   1   |   " />    |
|   <row id="   |   1   |   " />    |
|   <row id="   |   1   |   " />    |
<row id="1"/>
<row id="\i"/>
<row id="1" />
<row id="2" />
<row id="1" />
<row id="3" />
<row id="1" />
<row id="2" />
<row id="3" />
<row id="2" />
<row id="4" />
<row id="2" />
 /**
 * <p> Finds words that matches template and increases them by 1.
 * '_' in word template represents number.
 *
 * <p> E.g. if template equals 'Row="_"', then:
 * ALL Row=0 will be replaced by Row="1"
 * All Row=1 will be replaced by Row="2"
 * <p> Warning - your find template might not work properly if _ is the last character of it
 * etc.
 * <p> Requirments:
 * - Original text does not contain tepmlate string
 * - Only numbers in non-disrupted sequence are incremented and replaced
 * (i.e. from example below, if Row=4 exists in original text, but Row=3 not, than Row=4 will NOT be 
 * replaced by Row=5)
 */
def replace_inc(String text, int startingIndex, String findTemplate) {
    assert findTemplate.contains('_') : 'search template needs to contain "_" placeholder'
    assert !(findTemplate.replaceFirst('_','').contains('_')) : 'only one "_" placeholder is allowed'
    assert !text.contains('_____') : 'input text should not contain "______" (5 underscores)'
    while (true) {
        findString = findTemplate.replace("_",(startingIndex).toString())
        if (!text.contains(findString)) break;
        replaceString = findTemplate.replace("_", "_____"+(++startingIndex).toString())
        text = text.replaceAll(findString, replaceString)
    }
    return text.replaceAll("_____","") // get rid of '_____' character
}

// input
findTemplate = 'Row="_"'
path = /C:\TEMP\working_copy.txt/
startingIndex = 0

// do stuff
f = new File(path)
outText = replace_inc(f.text,startingIndex,findTemplate)
println "Results \n: " + outText
f.withWriter { out -> out.println outText }
println "Results written to $f"
<row id="1" />
<row id="1" />
<row id="1" />
<row id="1" />
<row id="1" />
$initialNum=1; $increment=1; $tmp = Get-Content input.txt | foreach {  $n = [regex]::match($_,'id="(\d+)"').groups[1
].value; if ($n) {$_ -replace "$n", ([int32]$initialNum+$increment); $increment=$increment+1;} else {$_}; }