这是我第一次真正需要写任何RegEx,但我还是输了。我需要找到与下面示例匹配的项目,其中*中的任何内容都可能发生变化。还有一些类似但没有我不想选择的换行符和空格的记录。空格的数量可以变化。如果有人可以提供帮助那就太棒了!以下是我想要搜索的示例:
inspect *DX-DATA-EX1*(*0000411*:*0000002*)
converting E-NUMB to A-NUMB
如果我的帖子太模糊(这里的第一篇文章,不确定要包括哪些内容),请注意混淆,所以我有上述内容。我需要以下(伪代码):
*anything*(*anything*)*newline* converting E-NUMB to A-NUMB
希望这稍微有用吗? :$
我只是尝试使用RegEx选项在Notepad ++中搜索文本文件。
答案 0 :(得分:1)
如果我理解正确,您的输入字符串应与此正则表达式匹配:
^[^\(]*\([^\)]*\)(\r\n?|\n\r?)+ +converting E-NUMB to A-NUMB$
说明:
^ The beginning of the string
[^\(]* Any characters at all (including new line) that are not an opening `(`
\( An opening `(`, escaped so that it is treated at its real value
[^\)]* Any characters that are not a closing `)`
\) A closing `)`, escaped so that it is treated at its real value
(\r\n?|\n\r?)+ Any combination of carriage return and line feed, one or more times
+ At least one space
converting E-NUMB to A-NUMB Exactly these characters
$ The end of the string