Notepad++ Replace new line inside text

2020-03-26 13:22发布

I have this sample, because is one of one million rows with that. I have this text:

<tr class="even">
<td><a href="http://www.ujk.edu.pl/">Jan Kochanowski 
University of Humanities and Sciences (Swietokrzyska Pedagogical 
University) / Uniwersytet Humanistyczno Przyrodniczy Jana Kochanowskiego
w Kielcach</a></td>

I want to replace to be like that:

<tr class="even">
<td><a href="http://www.ujk.edu.pl/">Jan Kochanowski University of Humanities and Sciences (Swietokrzyska Pedagogical University) / Uniwersytet Humanistyczno Przyrodniczy Jana Kochanowskiegow Kielcach</a></td>

I tried that REGEX: (.*) But didn't work.

3条回答
聊天终结者
2楼-- · 2020-03-26 13:42

Open Notepad++
Click Search >> Replace..

Replace with: \n

At the bottom you will find "Search Mode", click "Extended"

Live example here: http://postimg.org/image/c66pw8kkr/

查看更多
爷、活的狠高调
3楼-- · 2020-03-26 13:53

If you can't make jmstoker's solution work, try like this:

  • you need to check if the line breaks are just CRLF or just one of them, for that, click on the toolbar the icon "show all characters" or go to menu View -> Show Symbol -> Show all characters
  • in the replace dialog select the "Extended" search mode
  • in the "find what:" field, write this: \r\n (or just \r or just \n, basically match CR with \r and LF with \n)
  • leave the replace with field empty
  • once this is done, all the line breaks will have been replaced, but you want the <tr class="even"> to be on its own line, so just replace still using an extended search <tr class="even"><td> with <tr class="even">\r\n<td>

I'm guessing you also have rows with class "odd" or something like that so you might need to repeat that last step with the different class :)

查看更多
ら.Afraid
4楼-- · 2020-03-26 13:56

Open the replace window with Ctrl + H

Then enter

  • Find what: ([^>])[\r\n]{1,2}

  • Replace with: \1

  • Check Regular Expression


  • [^>] matches a character that isn't a >

  • The {1,2} protects against a file that may only have a newline and not a carriage return.

  • \1 replaces just the character that was in the grouping ( ).

查看更多
登录 后发表回答