简体   繁体   English

Notepad ++如何在行尾附近替换或添加某个符号

[英]Notepad++ how to replace or add a certain symbol near the end of the line

So i have a bunch of lines, that i need to add : or replace with another certain symbol near the end of the line so it doubles at the last :所以我有一堆行,我需要添加:或在行尾附近替换为另一个特定符号,以便它在最后加倍:

ROWERS:TREADMILL-1000M:SITUPS@100:CRUNCHES@10:TEST

So it will become所以会变成

ROWERS:TREADMILL-1000M:SITUPS@100:CRUNCHES@10::TEST

I thought it would be something simple such as (:$) but no i am having no luck我认为这会很简单,例如(:$)但不,我没有运气

To double the last : you may最后加倍:你可以

Find What : :[^:\\r\\n]*$查找内容:[^:\\r\\n]*$
Replace with : :$0替换为:$0

The :[^:\\r\\n]*$ pattern matches a : char that is followed with any 0+ chars other than : , CR and LF. :[^:\\r\\n]*$模式匹配一​​个:字符,后跟除: 、 CR 和 LF 之外的任何 0+ 字符。

Note that if you want to avoid adding a : in case the last : is already doubled, add (?<!:) lookbehind that will fail the match if there is a : before a : :请注意,如果您想避免添加:以防最后一个:已经翻倍,请添加(?<!:)后视,如果在:之前有:则匹配失败:

(?<!:):[^:\r\n]*$
^^^^^^

See NPP S&R settings and demo:请参阅 NPP S&R 设置和演示:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM