Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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!

like image 768
amefromdope Avatar asked Oct 26 '13 15:10

amefromdope


2 Answers

Try to replace this regex:

\s+,

With this:

,
like image 57
ProgramFOX Avatar answered Oct 13 '22 22:10

ProgramFOX


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: 
like image 45
hwnd Avatar answered Oct 13 '22 20:10

hwnd