Notepad++ 搜索和替换:删除“/"后的所有内容在每一行 [英] Notepad++ Search and Replace: delete all after "/" in each row

查看:305
本文介绍了Notepad++ 搜索和替换:删除“/"后的所有内容在每一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个纯文本文件,内容如下:

I have a plain text file with content like this:

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

问:如何在Notepad++中删除每一行/符号后的所有字符串?

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

所需的输出:

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

我正在对 / 之后的每个不同的字符串使用 Find-and-Replace 来执行此操作,但是组合太多了.

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

推荐答案

搜索:/.*,替换为空.

字符 / 只匹配 /.但是,. 匹配除换行符以外的任何字符,因此 .* 将匹配直到第一个换行符为止的一系列字符.您可以在此处找到演示:http://regex101.com/r/kT0uE3.

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.

如果您只想删除 / 行上的 last 之后的字符,则应使用正则表达式 /[^/]*$.您可以在此处找到解释和演示:https://regex101.com/r/sZ6kP7/74.

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.

这篇关于Notepad++ 搜索和替换:删除“/"后的所有内容在每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆