So ersetzen Sie das vierte Vorkommen von | in jeder Zeile in Notepad++ durch ein Leerzeichen

So ersetzen Sie das vierte Vorkommen von | in jeder Zeile in Notepad++ durch ein Leerzeichen

Ich habe die folgenden riesigen Zufallsdaten

1231286234|453|1234|xxx|aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv
1231286234|453|1234|xxx| aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv
1231286234|453|1234|xxx |aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv
1231286234|453|1234|xxx | aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv

die Linien sind riesig und die Daten sind zufällig, ich möchte, dass sie so sind

1231286234|453|1234|xxx aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv
1231286234|453|1234|xxx aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv    
1231286234|453|1234|xxx aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv
1231286234|453|1234|xxx aabbc|xcvxcvxcv|xcvxcvxcv|Xcvxcvxcv

Antwort1

Dies funktioniert für das von Ihnen bereitgestellte Beispiel.

Find what: (\w*\|\w*\|\w*\|\w*)([\|\s]*)([\w\|]*)
Replace with: \1 \3

Search mode: Regular expression

Beispiel

Antwort2

  • Ctrl+H
  • Finde was:^(?:[^|]+\|){3}.*?\K\h*\|\h*
  • Ersetzen durch: <-- ein Leerzeichen
  • ÜBERPRÜFEN Umwickeln
  • ÜBERPRÜFEN Regulären Ausdruck
  • DEAKTIVIEREN . matches newline
  • Replace all

Erläuterung:

^               # beginning of line
  (?:           # start non capture group
    [^|]+       # 1 or more non pipe
    \|          # a pipe, have to be escaped as it's special character for regex
  ){3}          # end group, must appear 3 times
  .*?           # 0 or more any character but new line, not greeedy
  \K            # forget all we have seen until this position
  \h*           # 0 or more horizontal spaces
  \|            # a pipe, have to be escaped as it's special character for regex
  \h*           # 0 or more horizontal spaces

Bildschirmaufnahme (vorher):

Bildbeschreibung hier eingeben

Bildschirmaufnahme (nachher):

Bildbeschreibung hier eingeben

verwandte Informationen