Selecting all words inside curly brackets to paste into a new file with Notepad++

0

I have a dictionary document that uses the following syntax:

\lem{WORD}{POS}{PL}{DEFINITION}

\lem{WORD}{POS}{PL}{DEFINITION}

\lem{WORD}{POS}{PL}{DEFINITION}

and etc..

I want to select every WORD and copy-paste it into a new file.

Using the find function with the regular expression of \\lem\{\w+\} I can highlight all the words I need (and I could easily delete the fluff), however I can't figure out how to select them.

Is this possible? If not, is there some other program I could use?

Manofzelego

Posted 2016-02-20T23:33:03.233

Reputation: 3

Answers

0

You should install the Python Script plugin into NP++ and the python interpreter for win (https://www.python.org/downloads/ , I use v2.7.11). Don't forget to allow the installer to append the directory of python.exe to the PATH.

Then selecting Plugins->Python Script->New script, you you have to type some name of the script's code. I used cplemname for this code:

from Npp import *
import re

content = editor.getText()
temp=""

matches = re.findall( '\\lem{(\w+)}', content)

for m in matches:
    temp += m + "\n"

editor.copyText( temp)

Then inside the tab that your definitions are, just select Plugins->Python Script->Scripts->cplemname. Your words should be the content of the clipboard at this point, ready to be pasted.

Gombai Sándor

Posted 2016-02-20T23:33:03.233

Reputation: 3 325

I've done the above and this appears to crash Npp. – Manofzelego – 2016-02-21T18:38:32.777

Mine is v6.8.8 and does it well. – Gombai Sándor – 2016-02-21T20:34:59.090

Turns out the plugin, DSpellCheck must have been causing a conflict, after uninstalling that your solution worked. – Manofzelego – 2016-02-22T02:54:25.500