Match rest of string with Regex in Notepad++ [duplicate] - regex

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

Related

Regex to pull out text between two strings [duplicate]

This question already has answers here:
Regex catch string between two strings, multiple lines
(4 answers)
Closed 2 years ago.
I'm trying to get the text from the [QOUTE] and [/QUOTE] but can seem to get it correctly. I'm just trying to pick it out and delete it. So I want to extract the text within as well as the actual HTML [QUOTE] parts. Just want to get rid of that entire code block via regex:
What I'm working with:
\[QUOTE(.+)|\[\/QUOTE]|
Text Example:
[QUOTE="", post: 1910681, member: 001""]
This is where the quote is located
[/QUOTE]
[URL unfurl=""true""]https://www.google.com[/URL]
Assuming those tags can't be nested, you can use the following regex with the single-line flag to match the tags and their content :
\[QUOTE\b.*?\[/QUOTE]
You can try it here.

Regexp - exclude pattern using negative lookahead [duplicate]

This question already has answers here:
Webpack regex test that matches *.ts but not *.d.ts
(1 answer)
Regex: match everything but a specific pattern
(6 answers)
Closed 2 years ago.
I've inside my company a deployment process called XL-Deploy.
XL-Deploy give me possibility to replace some mustach variable by value stored in XL-Deploy library
like Jenkins for comparison.
My problem with this application come with file extension. Yes, XL-Deploy need to specify using regexp wich file type need to be scan for variable replacement.
I'm not a pro with regexp but my company give me this regexp work perfectly when file are basic (foo.bar, index.php, test.html, etc..) but in my case not working because my config file name is config.ini.php.
I've try 1 day without success to create regexp working for exclude my config.ini.php.
Original work regexp for all file following this pattern: index.html, test.php, foo.bar
(.+.(?!php).*)
I've try (.+.(?!ini\.php).*) but for an unknow reason i dont understand when i add dot in negative lookahead my group stop working, because i need a matching for config.ini.php.
Thank you in advance for your help really needed :)
Have a good dev
William

Regular Expression Replace on Notepad++ [duplicate]

This question already has answers here:
Notepad++ v4.2.2. regular expressions to match and replace all text between two tags
(2 answers)
Closed 3 years ago.
I need a regular expression to replace the value in XML tags. I need to find * and replace it with XXXXX. I made an attempt to do this but its giving me "invalid regex".
<TAG>\('(.*?'\)</TAG>
// replace with:
<TAG>XXXXX</TAG>
I suspect that your actual starting content is something like this:
<TAG>some content here</TAG>
If you want to mask the content of such tags, you may try the following find and replace, in regex mode:
Find: <TAG>(.*?)</TAG>
Replace: <TAG>XXXXX</TAG>
Demo
Note that in general it is not desirable to manipulate nested content like XML/HTML using regex. But sometimes, e.g. when using tools like NPP, we are forced to do this. My answer should work fine assuming you are only targeting <TAG> elements which have no other children tags inside of them.

Regex help to filter only 720p [duplicate]

This question already has answers here:
What special characters must be escaped in regular expressions?
(13 answers)
Closed 4 years ago.
I'd like to setup auto download of some Anime using an RSS feed, but only 720p versions. The format never changes and it always looks like below.
[Blahblah] Blahepisode - 12 [720p].mkv
Here is the regex I have come up with but cannot get to work properly.
/.\+[720p]+/g
Any help would be appreciated!
Assuming you have lines that look like your example, it will be mached with the following Regex:
.+(?:\[720p\].mkv)
It maches one or more chacacters at start, followed by '[720p].mkv'.
Note that the Square brackets are escaped to '\[' and '\]', otherwise they have special meaning.
if you only need '[720p]' then you can use:
\[720p\]

Sublime text regex - remove text in parenthesizes [duplicate]

This question already has answers here:
My regex is matching too much. How do I make it stop? [duplicate]
(5 answers)
How can I remove text within parentheses with a regex?
(9 answers)
Closed 4 years ago.
I am having list on telephone numbers in my js file, and some of them have in parenthesizes translations that I don't need:
Azerbaijan (Azərbaycan)
I wont to find regex in sublime to do that, but I cannot find the right command. I have tried:
((.))
((*))
\(.*)\
\(.*\)
But I aways remove something different ... If someone know the solution, please help.
Ok as Paul Bak said the (.*) works at his computer, and it does work, just that my js file is compressed all in same line so it removes everything after the (...
I beautified js and use this regex and now it is solved.