0

I have a file that I'm cleaning up, the file structure is kinda corrupted but there is a possible way of fixing.

Problem

1|firstname|lastname CRLF    
|address|Tel|1|firsname|lastname|address|Tel|

Theoretically this problem could be solved by removing the CRLF and find the second |1| in a line and move it to a new line. I tried doing this manually but I later noticed that the file is big and it's goning to take some time to cleanup.

I need an output to be like this:

1|firstname|lastname|address|Tel 
1|firstname|lastname|address|Tel
2
  • "Good day Bloggers" - this isn't a blog and majority of users aren't bloggers here(:, showing some respect by considering you audience would be a positive start for your question. Sep 7, 2017 at 7:15
  • my sincere apologies. Sep 7, 2017 at 7:16

2 Answers 2

1

I've found a two step solution:

  1. remove line breaks:
    • open find / replace dialog (CTRL+H)
    • select "regular expression"
    • find what \R
    • Replace to (nothing)
    • press "replace all"
  2. insert line break before each |1|:
    • find what: \|1\|
    • replace to: \n1|
1
  • That was magic, thanks a lot Máté Juhász, it worked perfectly fine. Sep 7, 2017 at 7:33
0

A single step could be:

  • Find what: ^(.*)\R?(.*?)\|(?=1\|)
  • Replace with: $1$2\n or $1$2\r\n depending on platform
  • Replace all

Do not check . matches newline

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .