简体   繁体   English

在notepad ++中删除= character之前的文本

[英]Remove text before = character in notepad++

First the text looked like this: 首先,文本看起来像这样:

Ab Yz=15,Cd Wx=2,Ef Tu=20,...

I replaced all , with \\r\\n , so the text looked like this: 我全部换成,\\r\\n ,所以文字是这样的:

Ab Yz=15
Cd Wx=2
Ef Tu=20

Than I wanted only the numbers after the = and replaced ^.+[=] with "blank" and my result was just 20 比我只想在=之后的数字并用“空白”替换^.+[=]而我的结果只有20
Does Notepad++ think, that the whole document only has a single line and takes the last = and deletes everything before that? Notepad ++是否认为,整个文档只有一行并取出last =并删除之前的所有内容?
How can I fix this? 我怎样才能解决这个问题? Oh and how can I remove the text after the = ? 哦,我怎么能删除=后的文字? (including =) (包括=)

Edit: I also tried ^.+[\\=] , ^.+(=) and ^.+(\\=) but I got the same result. 编辑:我也试过^.+[\\=]^.+(=)^.+(\\=)但我得到了相同的结果。

I guess you have unintentionally checked . 我想你无意中检查过了 matches newline option which makes a . 匹配newline选项,使得. in a regex to go beyond a line - it will match newlines as well (AKA DOTALL modifier). 在正则表达式中超越一行 - 它也将匹配换行符(AKA DOTALL修饰符)。 So you should uncheck it. 所以你应该取消选中它。

Also there is no need to do this job in two separate steps. 此外,没有必要分两个步骤完成这项工作。 Use regex [^=]+=(\\d+),? 使用正则表达式[^=]+=(\\d+),? and replace with \\1\\n 并替换为\\1\\n

This will turn such an input string: 这将转换这样一个输入字符串:

Ab Yz=15,Cd Wx=2,Ef Tu=20,Ef Tu=20,Ef Tu=20,Ef Tu=20,Ab Yz=15,Cd Wx=2,Ef Tu=20,Ef Tu=20,

To: 至:

15
2
20
20
20
20
15
2
20
20

Use Regular expressions in the left-bottom side of Replace window and find ([AZ]+) ([AZ]+)= replace with empty string. 使用“ 替换”窗口左下角的正则表达式 ,找到([AZ]+) ([AZ]+)=替换为空字符串。

More info here . 更多信息在这里

To change all in one pass, you could do: 要一次性更改所有内容,您可以执行以下操作:

  • Find what: (?:^|,)[^=]+=([^,]+)(?:,|$) 找到: (?:^|,)[^=]+=([^,]+)(?:,|$)
  • Replace with: $1\\r\\n 替换为: $1\\r\\n
  • Replace all 全部替换

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

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