简体   繁体   English

试图用通配符替换文本字符串是notepad ++

[英]Trying to replace text string is notepad++ with wildcards

I am trying to replace text in a kicad program using notepad++. 我正在尝试使用记事本++替换kicad程序中的文本。 I am having trouble using wild cards. 我在使用通配符时遇到问题。

This string I am trying to find is one similar to this... 我要查找的该字符串与此类似。

(fp_text reference J2 (at -8.30084 1.4004 270) (fp_text引用J2(位于-8.30084 1.4004 270)

J2 is a wild card, but will not be changed and it can be anywhere from 2 to 5 characters long) J2是通配符,但不会更改,它的长度可以是2到5个字符。

-8.30084 can be any number that I want to change to zero -8.30084可以是我想要更改为零的任何数字

1.4004 can be any number that I want to change to zero 1.4004可以是我想要更改为零的任何数字

270 will not change, no matter what the number is. 不管数字是多少,270都不会改变。

In the end, I want the string to be 最后,我希望字符串是

(fp_text reference J2 (at 0 0 270) (fp_text参考J2(在0 0 270)

If in understand correctly you're looking for a regex to match that and replace the first and second (but not the third) number with 0. Without knowing what are valid characters for the token you have as J2 I'll assume that it's any non-space character. 如果正确理解,您正在寻找一个正则表达式来匹配该正则表达式,并用0替换第一个和第二个(而不是第三个)数字。不知道您作为J2拥有的令牌的有效字符是什么,我假设它是非空格字符。

You can reference a capture group within your replacement string. 您可以在替换字符串中引用捕获组 So you can capture the parts you want to preserve. 因此,您可以捕获要保留的部分。 (In the example below I also capture other unknown parts of the string, but that's not really necessary. (在下面的示例中,我还捕获了字符串的其他未知部分,但这并不是必须的。

The regex should be something like: 正则表达式应类似于:

(\S)\s\(at ([-+]?\d*\.?\d+) ([-+]?\d*\.?\d+) ([-+]?\d*\.?\d+)\)

And your replacement will be something like: 您的替换将是这样的:

\1 (at 0 0 \4)

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

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