简体   繁体   English

在记事本中使用正则表达式++

[英]Using regex in notepad++

I have a text file which contains some lines this 我有一个文本文件,其中包含一些行

something1 1.2 MB
something2 5.3 MB

I want to remove (XX MB), so I did this in notepad++ 我要删除(XX MB),所以我在记事本++中完成了此操作

find what : *.*[ MB] 找到什么: *.*[ MB]

replace with: 用。。。来代替:

Regular expression 正则表达式

But it says invalid regular expression. 但是它说无效的正则表达式。 How can I fix that? 我该如何解决?

You might try: 您可以尝试:

Find: 找:

 \d*\.\d* MB

(yes, there's a space before the first \\d ). (是的,第一个\\d之前有一个空格)。

Replace with nothing. 一无所有。

\\d stands for a digit in regex, and you need to escape the dot since the dot is a wildcard in regex. \\d在正则表达式中代表数字,并且您需要对点进行转义,因为该点在正则表达式中是通配符。 * is an operator and means 0 or more times. *是运算符,表示0次或多次。 The square brackets is a character class and would otherwise match any one of space, M or B. Just remove them here. 方括号是字符类,否则将匹配空格M或B中的任何一个。只需在此处将其删除即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM