0

I use VSCode for salesforce and I have hundreds of fieldsets in the sandbox, I would like to use REGEX to find all XML files that contains these 2 words in any order:

LLC_BI__Stage__c 
LLC_BI__Status__c

I have tried using these REGEX but it did not work, I am assuming because the strings are in different lines:

(?=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.g, this XML File contains the 2 strings and should be returned

<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>
Sam
  • 487
  • 4
  • 12
  • 31
  • On Linux go to folder where all of your files are saved: `grep -l LLC_BI__Stage__c * | xargs grep -l LLC_BI__Status__c` should give you the list you want, on windows just use `findstr` – Allan Aug 15 '19 at 04:26

1 Answers1

1

You could use an alternation to find either one of them and according to this post use [\s\S\r] to match any character including newlines.

If there is an issue using [\s\S\r] you migh tuse [\S\r\n\t\f\v ]* instead.

(?:LLC_BI__Stage__c[\S\s\r]*LLC_BI__Status__c|LLC_BI__Status__c[\S\s\r]*LLC_BI__Stage__c)

Explanation

  • (?: Non capturing group
    • LLC_BI__Stage__c[\S\s\r]*LLC_BI__Status__c Match first part till second part
    • | Or
    • LLC_BI__Status__c[\S\s\r]*LLC_BI__Stage__c Match second part till first part
  • ) Close group

Regex demo 1 and Regex demo 2

The fourth bird
  • 154,723
  • 16
  • 55
  • 70