简体   繁体   English

notepad++ 用 , 替换空格和

[英]notepad++ replace space and , with ,

i am completely bad with replace option in notepad++ but i use it to edit my txt files and some of the books for my kindle in txt format.我对记事本++中的替换选项完全不满意,但我用它来编辑我的txt文件和一些txt格式的kindle书籍。

The problem is, in some lines i've got this problem:问题是,在某些方面我遇到了这个问题:

example例子

Emily was a pretty girl , but noone realy liked her.艾米丽是个漂亮的女孩,但没有人真正喜欢她。

I would be realy greatfull is someone can help me to replace this space-newline-come to come so the text will look like this我真的很高兴有人可以帮我替换这个空格换行来来所以文本看起来像这样

Emily was a pretty girl, but noone realy liked her.艾米丽是个漂亮的女孩,但没有人真正喜欢她。

Thank you!谢谢!

Try to replace this regex:尝试替换此正则表达式:

\s+,

With this:有了这个:

,

Another option you could do here is use a Negative Lookahead .您可以在这里做的另一个选择是使用Negative Lookahead

Find: \s+(?![^,])
Replace: 

Regular expression:正则表达式:

\s+            whitespace (\n, \r, \t, \f, and " ") (1 or more times)
 (?!           look ahead to see if there is not:
  [^,]         any character except: ','
 )             end of look-ahead

Or lookahead to see if there is not word characters.或者先行看看有没有单词字符。

Find: \s+(?!\w)
Replace:

Regular expression:正则表达式:

\s+            whitespace (\n, \r, \t, \f, and " ") (1 or more times)
 (?!           look ahead to see if there is not:
  \w           word characters (a-z, A-Z, 0-9, _)
 )             end of look-ahead

You could also use a Positive Lookahead here to look ahead to see if there is non-word characters.您也可以在此处使用 Positive Lookahead 来提前查看是否有非单词字符。

Find: \s+(?=\W)
Replace: 

In addition to ProgramFox's answer, I would add this link, this may help you for further regex including this space: 除了ProgramFox的答案外,我还要添加此链接,这可能有助于您获得包括以下内容的更多正则表达式:

http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions

Thanks 谢谢

Yet another Positive Lookahead as follows另一个积极的前瞻如下

Find    : \s+(?=,)
Replace :

Regular expression:正则表达式:

\s+            whitespace (\n, \r, \t, \f, and " ") (1 or more times)
 (?=           look ahead to see if there is :
   ,           comma
 )             end of look-ahead

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

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