Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ Search and Replace: delete all after "/" in each row

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.

like image 858
Ing. Michal Hudak Avatar asked Jan 16 '14 14:01

Ing. Michal Hudak


People also ask

How do you delete everything after a line in Notepad?

Ctrl-F2 on the line you wish to keep. This bookmarks the current line (you will see a blue circle at start of line). Then Use the “remove unmarked lines” which is under “Search” main menu, then “Bookmark” item. With “normal” size files, those work find, followed by DELETE or BACKSPACE to delete them.

How do you delete all text after a character or string in Notepad++?

If you want to delete all the text after a character or string (to the right) in Notepad++ you would need to make use of regex. So, simply add . * to delete all characters after the string or character on each that you want to delete from a line.


1 Answers

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.

like image 73
The Guy with The Hat Avatar answered Sep 22 '22 05:09

The Guy with The Hat