5

I would like to get only words which containing specific string in notepad++ result. There are tons of examples for finding word but non oftem showing how to get only those words in result page.

For example DE2KXXXXXX -> there are different of this word (X ares different strings in text document)

So i want to get only these words not whole line. i checked everywhere and it shows only get lines which containing words or strings.

But my request is only get words containing string as start with DX2K and 6 string in word.

I just want to copy all of them to my excel. But notepad++ is getting whole line in result.

Below, X are any string maybe A-Z or 0-9 . So it will start with D and third character is 2 and 4th is K and then strings.

Example text:

The right-click > W > T DE2K12XXXX shortcut eliminates DE2K1XX3XX the need to open Notepad first. It will create a text DE2K1XX5XX document ready for file DE2K1XXXXX naming and then all you have to do DX2K1X5XXX is hit Enter to open the text DE2K1XXX4X document for editing (hit CTRL+S to save DE2K1X2XXX your changes and you've got a very DE2K1XX3XX streamlined text-document-creating workflow).

Notepad++ Result must be:

DE2K12XXXX
DE2K1XX3XX
DE2K1XX5XX
DE2K1XXXXX
DX2K1X5XXX
DE2K1XXX4X
DE2K1X2XXX
DE2K1XX3XX
1
  • 1
    So you want to find all instances of DE2KXXXXXX and save them into a new file?
    – MonkeyZeus
    Aug 2, 2019 at 13:02

2 Answers 2

4

Do it this way:

Step 1 : Replace all using

Search string: (DE2K\w*)
Replace string: \n\1\n

This will give the following result on your test data:

enter image description here

Step 2 : Do Mark All of the same string DE2K(\w*) with the option "Bookmark line", giving:

enter image description here

Step 3 : Use menu Search > Bookmark > Remove Unmarked Lines, giving:

enter image description here

1
  • solved issue. thank you Aug 2, 2019 at 15:56
1
  • Ctrl+H
  • Find what: .*?(\bDE2K\w{6}\b)(?:(?!\bDE2K\w{6}\b).)*
  • Replace with: $1\n OR $1\r\n
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

.*?         # 0 or more any character but newline
(           # start group 1
  \b        # word boundary
  DE2K      # literally
  \w{6}     # 6 word character
  \b        # word boundary
)           # end group 1
(?:         # non capture group (Tempered greedy token)
  (?!       # negative lookahead, make sure we haven't after:
    \b      # word boundary
    DE2K    # literally
    \w{6}   # 6 word character
    \b      # word boundary
  )         # end lokkahead
  .         # any character but newline
)*          # end group, may appear 0 or more times

Replacement:

$1          # content of group 1 (i.e. DE2KXXXXXX)
\n          # line break (you may use \r\n if wanted)

Result for given example:

DE2K12XXXX
DE2K1XX3XX
DE2K1XX5XX
DE2K1XXXXX
DE2K1XXX4X
DE2K1X2XXX
DE2K1XX3XX

Screen capture:

enter image description here

2
  • i could not get words as like you on my result page. Aug 8, 2019 at 16:07
  • @user1070082: Strange, as shown in capture screen, it works fine. Are you doing exactly what I explain? What result do you get?
    – Toto
    Aug 8, 2019 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .