Deleting sections of data that start and end with the same characters based on a string of text contained within the section
-
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
-
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 ourNodeBBsite !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
- SEARCH
-
REPLACE
Leave EMPTY -
Tick the
Wrap aroundoption, preferably -
Select the
Regular expressionsearch mode -
Click on the
ReplaceorReplace Allbuttons
Of course, replace in the search regex, any
xchar by a letter and any#by a digit !Best Regards,
guy038
-
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