Community
    • Login

    Deleting sections of data that start and end with the same characters based on a string of text contained within the section

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    sectiondeletestringcharacters
    2 Posts 2 Posters 540 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ruby PierceR Offline
      Ruby Pierce
      last edited by

      Hello there,

      I have a file that contains repeated sections of data, starting with a ‘{’ and ending with a ‘},’ but the data within these sections changes (field names stay the same) i.e. ‘identificationNumber’, ‘sizeandtypecode’ etc.
      I need a way to be able to search the whole file for specific identification numbers but delete the whole section the id number is contained within. - starting with { and ending with },

      {
      “identificationNumber” : “ABCD1234567”,
      “sizeAndTypeCode” : “45G0”,
      “shippingLine” : “MSC”,
      “shipsAgent” : “PORTSATLANTIC”,
      “transitDirection” : “EXPORT”,
      “isLaden” : true,
      “grossWeightKG” : 27468,
      “portOfDischargeCode” : “BEANR”,
      “finalPortOfDischargeCode” : “USNYC”,
      “seals” : [
      {
      “number” : “0990682”,
      “conditionCode” : “INTACT”,
      “sealedBy” : “carrier”
      }
      ]
      },
      {
      “identificationNumber” : “ABCD4561239”,
      “sizeAndTypeCode” : “45G0”,
      “shippingLine” : “MSC”,
      “shipsAgent” : “PORTSATLANTIC”,
      “transitDirection” : “EXPORT”,
      “isLaden” : true,
      “grossWeightKG” : 27468,
      “portOfDischargeCode” : “BEANR”,
      “finalPortOfDischargeCode” : “USNYC”,
      “seals” : [
      {
      “number” : “0990682”,
      “conditionCode” : “INTACT”,
      “sealedBy” : “carrier”
      }
      ]
      },
      {
      “identificationNumber” : “ABCD7894223”,
      “sizeAndTypeCode” : “45G0”,
      “shippingLine” : “MSC”,
      “shipsAgent” : “PORTSATLANTIC”,
      “transitDirection” : “EXPORT”,
      “isLaden” : true,
      “grossWeightKG” : 11800,
      “portOfDischargeCode” : “BEANR”,
      “finalPortOfDischargeCode” : “USNYC”,
      “seals” : [
      {
      “number” : “0990288”,
      “conditionCode” : “INTACT”,
      “sealedBy” : “carrier”
      }
      ]
      },

      Thanks in advance,

      Ruby

      1 Reply Last reply Reply Quote 0
      • guy038G Offline
        guy038
        last edited by guy038

        Hello, @ruby-Pierce and All,

        First, I don’t know if you do use the simple double quote char " or if you need the opening and ending quotation marks ( the “ and ” chars with Unicode code-points \x{201C} and \x{201D} ), automatically provided by our NodeBB site !

        Anaway, here is a solution :

        • Open the Replace dialog ( Ctrl + H )

          • SEARCH ^{\R“identificationNumber” : “xxxx#######”,(?s).*?^},(\R|\z)     if couples of “ and ” are used

          OR

          • SEARCH ^{\R"identificationNumber" : "xxxx#######",(?s).*?^},(\R|\z)     if the " char is only used

        • REPLACE Leave EMPTY

        • Tick the Wrap around option, preferably

        • Select the Regular expression search mode

        • Click on the Replace or Replace All buttons

        Of course, replace in the search regex, any x char by a letter and any # by a digit !

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors