This question already has answers here:
How to remove everything after a certain character? (notepad++)
(2 answers)
Closed 3 years ago.
I have the following json file:
[{"accountId":"fe1a8715-794b-4fd9-84df-ccbc7dd1c0c6","id":"9314c53324","state":"Processed","moderationState":"OK","reviewState":"None","privacyMode":"Private","processingProgress":"100%","failureCode":"None","failureMessage":"","externalId":null,"externalUrl":null,"metadata":null,"insights":{"version":"1.0.0.0","duration":"0:00:20.6","sourceLanguage":"en-US","sourceLanguages":["en-US"],"language":"en-US","languages":["en-US"],"labels":[{"id":1,"name":"outdoor","language":"en-US","instances":[{"confidence":0.9964,"adjustedStart":"0:00:00","adjustedEnd":"0:00:04.266","start":"0:00:00","end":"0:00:04.266"},{"confidence":0.9981,"adjustedStart":"0:00:04.267","adjustedEnd":"0:00:10.666","start":"0:00:04.267","end":"0:00:10.666"},{"confidence":0.9966,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:17.066","start":"0:00:10.667","end":"0:00:17.066"},{"confidence":0.969,"adjustedStart":"0:00:17.067","adjustedEnd":"0:00:20.6","start":"0:00:17.067","end":"0:00:20.6"}]},{"id":2,"name":"mountain","referenceId":"geological formation/natural elevation/mountain","language":"en-US","instances":[{"confidence":0.9574,"adjustedStart":"0:00:00","adjustedEnd":"0:00:04.266","start":"0:00:00","end":"0:00:04.266"},{"confidence":0.99,"adjustedStart":"0:00:04.267","adjustedEnd":"0:00:10.666","start":"0:00:04.267","end":"0:00:10.666"},{"confidence":0.9797,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:17.066","start":"0:00:10.667","end":"0:00:17.066"}]},{"id":3,"name":"snow","referenceId":"natural phenomenon/weather/snow","language":"en-US","instances":[{"confidence":0.9755,"adjustedStart":"0:00:00","adjustedEnd":"0:00:04.266","start":"0:00:00","end":"0:00:04.266"},{"confidence":0.998,"adjustedStart":"0:00:04.267","adjustedEnd":"0:00:10.666","start":"0:00:04.267","end":"0:00:10.666"},{"confidence":0.991,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:17.066","start":"0:00:10.667","end":"0:00:17.066"},{"confidence":0.9788,"adjustedStart":"0:00:19.2","adjustedEnd":"0:00:20.6","start":"0:00:19.2","end":"0:00:20.6"}]},{"id":4,"name":"nature","referenceId":"nature","language":"en-US","instances":[{"confidence":0.9946,"adjustedStart":"0:00:00","adjustedEnd":"0:00:04.266","start":"0:00:00","end":"0:00:04.266"},{"confidence":0.9959,"adjustedStart":"0:00:04.267","adjustedEnd":"0:00:10.666","start":"0:00:04.267","end":"0:00:10.666"},{"confidence":0.9792,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:17.066","start":"0:00:10.667","end":"0:00:17.066"},{"confidence":0.8443,"adjustedStart":"0:00:17.067","adjustedEnd":"0:00:19.2","start":"0:00:17.067","end":"0:00:19.2"}]},{"id":5,"name":"valley","language":"en-US","instances":[{"confidence":0.8591,"adjustedStart":"0:00:00","adjustedEnd":"0:00:04.266","start":"0:00:00","end":"0:00:04.266"},{"confidence":0.9502,"adjustedStart":"0:00:04.267","adjustedEnd":"0:00:10.666","start":"0:00:04.267","end":"0:00:10.666"},{"confidence":0.9092,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:17.066","start":"0:00:10.667","end":"0:00:17.066"}]},{"id":6,"name":"canyon","referenceId":"geological formation/natural depression/canyon","language":"en-US","instances":[{"confidence":0.8353,"adjustedStart":"0:00:06.4","adjustedEnd":"0:00:08.533","start":"0:00:06.4","end":"0:00:08.533"}]},{"id":7,"name":"covered","language":"en-US","instances":[{"confidence":0.8697,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:14.933","start":"0:00:10.667","end":"0:00:14.933"}]}],"scenes":[{"id":1,"instances":[{"adjustedStart":"0:00:00.4","adjustedEnd":"0:00:20.6","start":"0:00:00.4","end":"0:00:20.6"}]}],"shots":[{"id":1,"tags":["Outdoor"],"keyFrames":[{"id":1,"instances":[{"thumbnailId":"a137ab2a-f250-4ace-a71f-8a158517863b","adjustedStart":"0:00:00.4","adjustedEnd":"0:00:00.467","start":"0:00:00.4","end":"0:00:00.467"}]},{"id":2,"instances":[{"thumbnailId":"52d41f10-20e7-40c4-9426-d2482fd6ec71","adjustedStart":"0:00:16.667","adjustedEnd":"0:00:16.734","start":"0:00:16.667","end":"0:00:16.734"}]}],"instances":[{"adjustedStart":"0:00:00.4","adjustedEnd":"0:00:20.6","start":"0:00:00.4","end":"0:00:20.6"}]}],"blocks":[{"id":0,"instances":[{"adjustedStart":"0:00:00","adjustedEnd":"0:00:20.6","start":"0:00:00","end":"0:00:20.6"}]}],"textualContentModeration":{"id":0,"bannedWordsCount":0,"bannedWordsRatio":0,"instances":[]},"statistics":{"correspondenceCount":0,"speakerTalkToListenRatio":{},"speakerLongestMonolog":{},"speakerNumberOfFragments":{},"speakerWordCount":{}}},"thumbnailId":"116bfb86-5a32-41a3-9fda-2417beb52a18","detectSourceLanguage":false,"languageAutoDetectMode":"None","sourceLanguage":"en-US","sourceLanguages":["en-US"],"language":"en-US","languages":["en-US"],"indexingPreset":"Default","linguisticModelId":"00000000-0000-0000-0000-000000000000","personModelId":"00000000-0000-0000-0000-000000000000","isAdult":false,"publishedUrl":"https://rodmandev.streaming.mediaservices.windows.net/0c4d34a3-4415-4f56-a4e5-7b34292eb72d/DJI_0043mp4.sil.ism/manifest(encryption=cbc)","publishedProxyUrl":null,"viewToken":"Bearer=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiIyNWI5OTRiOC03NzQyLTQ2MmUtOWExMy0zMTYwMzMwNWQzOGQiLCJuYmYiOjE1NzY1MDQxNTUsImV4cCI6MTU3NjU0NzQxNSwiaXNzIjoiaHR0cHM6Ly9icmVha2Rvd24ubWUiLCJhdWQiOiJCcmVha2Rvd25Vc2VyIn0.KAvVIh7dlFqbELqv2wwHJZocHonIXOZCvff20t3KWKg"}]
I'm trying to remove all the text except the words in quotes that come after "name".
In Notepad++, using the find and replace function, I searched for .+?name":"(.+?)" and replaced it with \1.
That returns the following result:
outdoor mountain snow nature valley canyon covered ,"language":"en-US","instances":[{"confidence":0.8697,"adjustedStart":"0:00:10.667","adjustedEnd":"0:00:14.933","start":"0:00:10.667","end":"0:00:14.933"}]}],"scenes":[{"id":1,"instances":[{"adjustedStart":"0:00:00.4","adjustedEnd":"0:00:20.6","start":"0:00:00.4","end":"0:00:20.6"}]}],"shots":[{"id":1,"tags":["Outdoor"],"keyFrames":[{"id":1,"instances":[{"thumbnailId":"a137ab2a-f250-4ace-a71f-8a158517863b","adjustedStart":"0:00:00.4","adjustedEnd":"0:00:00.467","start":"0:00:00.4","end":"0:00:00.467"}]},{"id":2,"instances":[{"thumbnailId":"52d41f10-20e7-40c4-9426-d2482fd6ec71","adjustedStart":"0:00:16.667","adjustedEnd":"0:00:16.734","start":"0:00:16.667","end":"0:00:16.734"}]}],"instances":[{"adjustedStart":"0:00:00.4","adjustedEnd":"0:00:20.6","start":"0:00:00.4","end":"0:00:20.6"}]}],"blocks":[{"id":0,"instances":[{"adjustedStart":"0:00:00","adjustedEnd":"0:00:20.6","start":"0:00:00","end":"0:00:20.6"}]}],"textualContentModeration":{"id":0,"bannedWordsCount":0,"bannedWordsRatio":0,"instances":[]},"statistics":{"correspondenceCount":0,"speakerTalkToListenRatio":{},"speakerLongestMonolog":{},"speakerNumberOfFragments":{},"speakerWordCount":{}}},"thumbnailId":"116bfb86-5a32-41a3-9fda-2417beb52a18","detectSourceLanguage":false,"languageAutoDetectMode":"None","sourceLanguage":"en-US","sourceLanguages":["en-US"],"language":"en-US","languages":["en-US"],"indexingPreset":"Default","linguisticModelId":"00000000-0000-0000-0000-000000000000","personModelId":"00000000-0000-0000-0000-000000000000","isAdult":false,"publishedUrl":"https://rodmandev.streaming.mediaservices.windows.net/0c4d34a3-4415-4f56-a4e5-7b34292eb72d/DJI_0043mp4.sil.ism/manifest(encryption=cbc)","publishedProxyUrl":null,"viewToken":"Bearer=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiIyNWI5OTRiOC03NzQyLTQ2MmUtOWExMy0zMTYwMzMwNWQzOGQiLCJuYmYiOjE1NzY1MDQxNTUsImV4cCI6MTU3NjU0NzQxNSwiaXNzIjoiaHR0cHM6Ly9icmVha2Rvd24ubWUiLCJhdWQiOiJCcmVha2Rvd25Vc2VyIn0.KAvVIh7dlFqbELqv2wwHJZocHonIXOZCvff20t3KWKg"}]
The problem is that I don't want to keep any text after covered.
I tried using .+?name":"(.+?)"(\S+) which removed some of the text I want to keep.
How do I fix this?
You should search using a pattern which targets the entire file:
Find: ^.*"name":"(.+?)".*$
Replace: $1
What is currently happening is that your pattern only targets everything up to the literal in quotes appearing after the key name. The content after that is not being replaced.
Demo