none
I need regular expression for find all words starting with ESGeneratedRPKey_ . Words can have _ and dot character and alphanumeric value. RRS feed

  • Question

  • Eg : Input string is 

    "this.Data.GetForRules(\"ICMTypeofAgreement\").ToString() == \"ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_0271102E-EE30-4801-83F1-92F56588827E\" && System.Convert.ToDateTime(this.Data.GetForRules(\"CreatedDate\")) > 5/1/2018 12:00:00 AM && 

    this.Data.GetForRules(\"ICMTypeofAgreement\").ToString() == \"ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_D5AC569C-9853-44B1-879D-25BA370AE990\" && this.Data.GetForRules(\"ICMAgreementSubtype\").ToString() != \"APA with exclusivity\" &&
     this.Data.GetForRules(\"ICMAgreementCode\").ToString().Contains(\"1\") == True" 

    and regular expression is (?<!\w)ESGeneratedRPKey_[A-Za-z0-9]\w+\b

    but this matches only ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping

    I want below 2 matches : ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_0271102E-EE30-4801-83F1-92F56588827E and ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_D5AC569C-9853-44B1-879D-25BA370AE990

    Thursday, May 3, 2018 11:47 AM

All replies

  • Try this expression:

       \bESGeneratedRPKey_.*?(?=")

    Do you need it in program or for manual searches in Editor?

    Thursday, May 3, 2018 12:47 PM
  • Depending on how varied the input string is, you might do better with simple string functions rather than regular expressions. This grabs out the agreement number.

                string keyPhrase = "ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_";
                string t1 = @"this.Data.GetForRules(\\\""ICMTypeofAgreement\\"").ToString() == \\""ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_0271102E-EE30-4801-83F1-92F56588827E\\"" && System.Convert.ToDateTime(this.Data.GetForRules(\\""CreatedDate\\"")) > 5/1/2018 12:00:00 AM && this.Data.GetForRules(\\""ICMTypeofAgreement\\"").ToString() == \\""ESGeneratedRPKey_ICMAgreementTypeandPurchasingEntityMapping.ICMTypeofAgreement_D5AC569C-9853-44B1-879D-25BA370AE990\\"" && this.Data.GetForRules(\\""ICMAgreementSubtype\\"").ToString() != \\""APA with exclusivity\""";
                string desiredResult = t1.Substring(t1.IndexOf(keyPhrase)+keyPhrase.Length,36
                    );
    Ethan


    Ethan Strauss

    Thursday, May 3, 2018 5:13 PM