notepad++ replace space and , with ,

这一生的挚爱 提交于 2020-01-01 09:27:32

问题


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.

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!


回答1:


Try to replace this regex:

\s+,

With this:

,



回答2:


Another option you could do here is use a 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.

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



回答3:


In addition to ProgramFox's answer, I would add this link, this may help you for further regex including this space:

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

Thanks



来源:https://stackoverflow.com/questions/19608329/notepad-replace-space-and-with

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!