17

I have a plain text file with content like this:

prežrať/RN
prežrieť/Z
prežrúc/zZ
prežuť/c
...

Q: How can I remove all strings after / symbol in every row in Notepad++?

Desired output:

prežrať
prežrieť
prežrúc
prežuť
...

I am doing this with Find-and-Replace for every different string after /, but there are too many combinations.

4 Answers 4

49

Search for: /.*, replace with nothing.

The character / matches just /. ., however, matches any character except newlines, so .* will match a sequence of characters up until the first newline. You can find a demonstration here: http://regex101.com/r/kT0uE3.

If you want to remove characters only after the last on the line /, you should use the regex /[^/]*$. You can find an explanation and demonstration here: https://regex101.com/r/sZ6kP7/74.

0
10

In regular expression mode

Find:

/.* 

Replace:

(empty) 
1
  • This answer helped me. Thank you
    – K.Hayoev
    Aug 11, 2018 at 14:08
6

Set find and replace to regular expression mode.
Find string: /.*
Replace String: (empty string)

Notepad++ find and replace is by default line ended (it won't go over multiple lines)

0
2

Using find and replace:

  • Hit CTRL-H to open the Replace dialogue box
  • enter /.* into "Find what"
  • leave "Replace with" empty
  • Select "Regular expression" (and .matches newline if it is single line)
  • Click on Replace

Here we go... You are done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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