3

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.

daminufe
  • 924
  • 1
  • 7
  • 13

3 Answers3

15

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 ( ).

jmstoker
  • 3,315
  • 22
  • 36
  • Are you not able to upgrade to v. 6.1.3? – jmstoker Sep 18 '13 at 00:22
  • Trying use \ instead of $. I've updated my solution. Both methods work in v 6.1.3 and I know the \ works back to version v4.9 – jmstoker Sep 18 '13 at 00:26
  • What to you have selected for Search Mode? – jmstoker Sep 18 '13 at 00:28
  • @alfasin Sorry, I got you confused with the OP, but I can confirm this regex works in Windows with Notepad++ v. 6.1.3. It works if the line ends with \r\n or just \n. – jmstoker Sep 18 '13 at 00:37
  • 1
    @alfasin Not sure what problem you have, but the regex is working fine. Unless you have some other file in your notepad++ or you missed something with "Direction" or the regular expression option. You could try selecting the whole text, check "In selection" and click the corresponding Replace All. – Jerry Sep 18 '13 at 04:39
3

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/

Ahmed
  • 255
  • 2
  • 7
  • 17
2

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 :)

Julien
  • 2,217
  • 2
  • 28
  • 49
  • Doesn't work like that, because if I relace all \n, I will get just one line html. – daminufe Sep 18 '13 at 08:43
  • if you took the time to read my complete answer you would see that the last step takes care of putting the back in its own line.. – Julien Sep 18 '13 at 12:47