How to keep special strings in notepad++ and delete other strings?

How to keep special strings in notepad++ and delete other strings?

I want to find some special strings in my text and then delete other strings.

For example in this sentence:

( (IP-MAT (CONJ vnnd)
      (NP-NOM (D das) (N wort))
      (BED war)
      (PP (P bey)
          (CODE [2])
          (NP-DAT (NPR Gott)))
      (. ,))

I want to regularly keep: CONJ D N BED P NPR. and delete other strings in this text.

Second example:

( (IP-MAT-SPE (NP-NOM-LFD (D diser) (NPR Jhesus)
 (, ,)
 (CP-REL-SPE (WNP-1 (WPRO wilcher)) (C 0)
 (IP-SUB-SPE (NP-NOM T-1) (PP (P von) (NP-DAT (PRO euch))) (BEPI ist) (RP auff) (VAN genomen) (PP (P gen) 
 (NP-ACC-XXX (NPR hymel)))))) 
 (, ,) 
 (NP-NOM-RSP (D der)) (RDPI wirt) (VB komen)
(PP (P wie) (CP-ADV-SPE (C 0) (IP-SUB-SPE (NP-NOM (PRO yhr)) (NP-ACC-2 (PRO yhn)) (VBN gesehen) (HVPI habt) 
(IP-INF-SPE (NP-ACC-SBJ ICH-2) (PP (P gen)
(NP-ACC-XXX (NPR hymel))) (VB faren)))))
 (. .)) 

and I want to change them to this :

D NPR , WPRO C NP-NOM P PRO BEPI RP VAN P NPR , D RDPI VB , P C PRO PRO VBN HVPI NP-ACC-SBJ P NPR VB . –

答案1

Welp, sounds like you can do something like this:

Find:

(?:(?!\n\n).(?<!\n\n))*?\(([\w,.-]+)\s+[\w,.-]+\)+|(?:(?!\n\n).(?<!\n\n))+$

Replace with:

$1 

[Dollar, then "1", then space]

regex101 demo

Try to get one of the latest notepad++ versions if this doesn't work and make sure you checked 'regular expressions' in the Search&Replace dialog box and checked '. match newlines'.

相关内容