Regex 使用正则表达式查找包含特定字符串的所有XML文件
我使用VSCode for salesforce,沙箱中有数百个字段集,我想使用REGEX查找所有XML文件,其中包含以下任意顺序的两个单词:Regex 使用正则表达式查找包含特定字符串的所有XML文件,regex,xml,visual-studio-code,Regex,Xml,Visual Studio Code,我使用VSCode for salesforce,沙箱中有数百个字段集,我想使用REGEX查找所有XML文件,其中包含以下任意顺序的两个单词: LLC_BI__Stage__c LLC_BI__Status__c 我尝试过使用这些正则表达式,但它不起作用,我假设是因为字符串在不同的行中: (?=LLC_BI__Stage__c)(?=LLC_BI__Status__c) ^(?=.*\bLLC_BI__Stage__c\b)(?=.*\bLLC_BI__Status__c\b).*$ (
LLC_BI__Stage__c
LLC_BI__Status__c
我尝试过使用这些正则表达式,但它不起作用,我假设是因为字符串在不同的行中:
(?=LLC_BI__Stage__c)(?=LLC_BI__Status__c)
^(?=.*\bLLC_BI__Stage__c\b)(?=.*\bLLC_BI__Status__c\b).*$
(.* LLC_BI__Stage__c.* LLC_BI__Status__c.* )|(.* LLC_BI__Status__c.* LLC_BI__Stage__c.*)
e、 这个XML文件包含2个字符串,应该返回
<displayedFields>
<field>LLC_BI__Amount__c</field>
<isFieldManaged>false</isFieldManaged>
<isRequired>false</isRequired>
</displayedFields>
<displayedFields>
**<field>LLC_BI__Stage__c</field>**
<isFieldManaged>false</isFieldManaged>
<isRequired>false</isRequired>
</displayedFields>
<displayedFields>
<field>LLC_BI__lookupKey__c</field>
<isFieldManaged>false</isFieldManaged>
<isRequired>false</isRequired>
</displayedFields>
<displayedFields>
**<field>LLC_BI__Status__c</field>**
<isFieldManaged>false</isFieldManaged>
<isRequired>false</isRequired>
</displayedFields>
有限责任公司金额
错误的
错误的
**有限责任公司**
错误的
错误的
有限责任公司
错误的
错误的
**有限责任公司的地位**
错误的
错误的
您可以使用查找它们中的任何一个,并根据此使用[\s\s\r]
匹配任何字符,包括换行符
如果存在使用[\s\s\r]
的问题,您可以使用[\s\r\n\t\f\v]*
代替
(?:LLC_BI__Stage__c[\S\s\r]*LLC_BI__Status__c|LLC_BI__Status__c[\S\s\r]*LLC_BI__Stage__c)
解释
非捕获组(?:
匹配第一部分到第二部分LLC\u BI\u阶段\u c[\S\S\r]*LLC\u BI\u状态\u c
或|
将第二部分匹配到第一部分LLC\u BI\u状态\u c[\S\S\r]*LLC\u BI\u阶段\u c
关闭组)
在Linux上,转到保存所有文件的文件夹:
grep-l LLC_BI__阶段__c*;xargs grep-l LLC_BI__状态__c
应该给你想要的列表,在windows上只需使用findstr