Gold.strike
Gold.strike

Reputation: 1287

How do I remove all before a specific text on each line in Notepad++?

I have a file containing a thousand lines like this:

N'AN2ID', N'Best. Fluorid premium (EL) AN2ID', 1, N'AN2ID', N'', 0, 0, 0, N'Anorganik Messlabor 1 (EG 36) - IC', NULL, N'IRCode', 0, 0, 0, 0, NULL, NULL, NULL, NULL, N'987b57da-dc85-4e5c-a36a-e40829ccc0e0', N'IonenC', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)

N'WE811M018', N'Abf. EOX', 1, N'', N'', 0, 0, 0, N'Feststoff-Probenvorbereitung', NULL, N'IRCode', 0, 1, 0, 0, NULL, N'e71f44e4-dff2-4d3a-8a64-655eeb16e1ff', NULL, NULL, N'987b57da-dc85-4e5c-a36a-e40829ccc0e0', N'FS-PV', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)

N'EW-EOX-FS', N'Extraktion EOX FS (ohne Vortest)', 1, N'', N'', 0, 0, 0, N'Probenaufarbeitung Lipophile Stoffe', NULL, N'IRCode', 0, 0, 0, 0, NULL, N'2f49c200-a06e-472d-94ca-e5a37eaceee7', NULL, NULL, N'987b57da-dc85-4e5c-a36a-e40829ccc0e0', N'LiposEOX', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)

On each line, I would like to remove all the text before this: "0, 0, 0, N'XXX'"

For example on the first row, all the text before N'', 0, 0, 0, N'Anorganik Messlabor 1 (EG 36) - IC' is N'AN2ID', N'Best. Fluorid premium (EL) AN2ID', 1, N'AN2ID', N'',

Is there a way to do it with a regular expression?

Upvotes: 0

Views: 862

Answers (3)

user557597
user557597

Reputation:

It can be done with this

Find (?m-s)^.+?(?=0,\s*0,\s*0,\s*N'[^'\r\n]*')
Replace with nothing.

https://regex101.com/r/rSEKAn/2

Upvotes: 1

Toto
Toto

Reputation: 91430

  • Ctrl+H
  • Find what: ^.*?(?= 0, 0, 0, N')
  • Replace with: LEAVE EMPTY
  • Replace all

Explanation:

^               : stat of line
.*?             : 0 or more any character but newline, not greedy
(?=             : start lookahead
   0, 0, 0, N'  : literally
)               : end lookahead
  • check Match case
  • check Wrap around
  • Check Regular expression
  • DO NOT CHECK . matches newline

Result for given example:

 0, 0, 0, N'Anorganik Messlabor 1 (EG 36) - IC', NULL, N'IRCode', 0, 0, 0, 0, NULL, NULL, NULL, NULL, N'987b57da-dc85-4e5c-a36a-e40829ccc0e0', N'IonenC', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)

 0, 0, 0, N'Feststoff-Probenvorbereitung', NULL, N'IRCode', 0, 1, 0, 0, NULL, N'e71f44e4-dff2-4d3a-8a64-655eeb16e1ff', NULL, NULL, N'987b57da-dc85-4e5c-a36a-e40829ccc0e0', N'FS-PV', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)

 0, 0, 0, N'Probenaufarbeitung Lipophile Stoffe', NULL, N'IRCode', 0, 0, 0, 0, NULL, N'2f49c200-a06e-472d-94ca-e5a37eaceee7', NULL, NULL, N'987b57da-dc85-4e5c-a36a-e40829ccc0e0', N'LiposEOX', 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)

Upvotes: 2

trincot
trincot

Reputation: 350290

You could do:

Find: ^.*?(0, 0, 0, N'.*)
Replace: $1

Clear the box: . matches newline.

Upvotes: 1

Related Questions