替换除注释行之外的每一行中所有出现的字符

Replace all occurrences of a character on every line excepting commented lines

我需要一种方法来将文件中每一行的所有字符 "y" 和 "r" 替换为 "n",但仅使用 EmEditor's built-in Regex++ (version 1.57 by Dr John Maddock). This regex flavor supports 以“>”开头的行除外固定长度的 lookbehind,也没有针对正则表达式的所有高级 .NET 增强功能。

这是一个示例输入文件:

> A header containing "y" and "r"    
tttttrtagggaar-rrgatctg--gcctrtcc---cacyaayygggayyyaggc

这里是替换的期望结果:

> A header containing "y" and "r"  
tttttntagggaan-nngatctg--gcctntcc---cacnaanngggannnaggc

能够一步完成这样的替换是最理想的。但目前我完全无法找到一个两步或基于脚本的解决方案 (EmEditor allows writing Windows Scripting Host macroses). I know that I can find all non-commented lines with regex ^(?!>).*$, but haven't found a way to select them in order to perform the replacement r|yn in the selection only (using the corresponding option in the "Replace" dialog)。

有没有办法用 EmEditor 实现这个?

由于 EmEditor 默认的正则表达式引擎是 Boost,您可以这样做:

查找:^>.*|([yr])

替换为:(?1:n:[=11=])

注意:多行模式应该打开。