I have a text file that I need to extract specific data elements from.

Example text:


I want to extract:

Darbinian Sevak 1306859178

Boonyaputthikul Robert 1700198801

How can do this with notepad++?

  • Welcome to Super User! What have you tried so far? Is your data formatted exactly as you have it above- one continuous line? – bertieb Apr 4 '18 at 15:16
  • You can use regex or you can use any programming language to do it. – GoutamS Apr 4 '18 at 15:35
  • Yes one continuous line and I can seem to get the expression correct in regex – Missy Apr 4 '18 at 15:42
  • What are the rules used for extraction? – Toto Apr 4 '18 at 15:48
  • I'm not certain what you mean by rules for extraction. I have a text file and right now I literally do a ctrl F to find NM1*71*1*, then I copy and paste the text following till the ~ into another document by hand. Problem is I can easily have over 1000 instances of NM1*71*1* in a document and I have 250 documents to go through. – Missy Apr 4 '18 at 16:37

This can't be done in a single step with Notepad++, you could do:

First step:

  • Ctrl+H
  • Find what: (?:^|\G).+?NM1\*71\*1\*(.+?)\*{4}XX\*(\d+)
  • Replace with: $1 $2\n
  • check Wrap around
  • check Regular expression
  • DO NOT CHECK . matches newline
  • Replace all


(?:             : non capture group
  ^             : beginning of line
 |              : R
  \G            : position of last match
)               : end group
.+?             : 1 or more any character, not greedy
NM1\*71\*1\*    : literally "MN1*71*1*", asterisk have to be escaped
(.+?)           : group 1, 1 or more any character, not greedy
\*{4}XX\*       : 4 asterisks, XX, then 1 asterisk 
(\d+)           : group 2, 1 or more digit


$1      : content of group 1
        : a space
$2      : content of group 2
\n      : line feed, you could change it for the linebreak you need

Result for given example:

Darbinian*Sevak 1306859178
Boonyaputthikul*Robert 1700198801

In a second step, you have to delete the last line.

  • Thank you so tremendously much, I will not forget how to do this! Works perfectly. – Missy Apr 4 '18 at 18:41
  • @Missy: You're welcome, glad it helps. – Toto Apr 4 '18 at 18:43
  • @Missy: Feel free to mark the answer as accepted, see: superuser.com/help/someone-answers – Toto Apr 4 '18 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.