find matching text and replacing next line Windows 10

Multi tool use
I know this question was asked already, but the answer was provided for Linux. I need to do this in Windows, either using R or Notepad++ or UltraEdit or something similar. I need to replace the line after each instance of "see_more" in json code that is not formatted properly.
Here's an example:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
}
{
I need to add a comma after the } in the middle so it looks like this:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
},
{
There are thousands of these instances in these files, so it would take a very long time to do it manually. Note that the url in the "see more" line changes.
If you need more information, please let me know. Thank you.
EDIT:
I figured this out, sort of. I recorded a macro (search for "see_more", move to the next line, add a comma) in TextPad and ran it to the end of the file. Pretty easy and fast, but I doubt this would work in anything much more complex.
json windows text replace editor
add a comment |
I know this question was asked already, but the answer was provided for Linux. I need to do this in Windows, either using R or Notepad++ or UltraEdit or something similar. I need to replace the line after each instance of "see_more" in json code that is not formatted properly.
Here's an example:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
}
{
I need to add a comma after the } in the middle so it looks like this:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
},
{
There are thousands of these instances in these files, so it would take a very long time to do it manually. Note that the url in the "see more" line changes.
If you need more information, please let me know. Thank you.
EDIT:
I figured this out, sort of. I recorded a macro (search for "see_more", move to the next line, add a comma) in TextPad and ran it to the end of the file. Pretty easy and fast, but I doubt this would work in anything much more complex.
json windows text replace editor
Is the}
always on it's own line? Do you only want to change}
to},
if"see_more":
exists? Or just any}
that exists in the document?
– John Kens
Dec 30 '18 at 1:01
Thank you for the reply, but I figured it out using a TextPad macro.
– user8229029
Dec 30 '18 at 1:26
add a comment |
I know this question was asked already, but the answer was provided for Linux. I need to do this in Windows, either using R or Notepad++ or UltraEdit or something similar. I need to replace the line after each instance of "see_more" in json code that is not formatted properly.
Here's an example:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
}
{
I need to add a comma after the } in the middle so it looks like this:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
},
{
There are thousands of these instances in these files, so it would take a very long time to do it manually. Note that the url in the "see more" line changes.
If you need more information, please let me know. Thank you.
EDIT:
I figured this out, sort of. I recorded a macro (search for "see_more", move to the next line, add a comma) in TextPad and ran it to the end of the file. Pretty easy and fast, but I doubt this would work in anything much more complex.
json windows text replace editor
I know this question was asked already, but the answer was provided for Linux. I need to do this in Windows, either using R or Notepad++ or UltraEdit or something similar. I need to replace the line after each instance of "see_more" in json code that is not formatted properly.
Here's an example:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
}
{
I need to add a comma after the } in the middle so it looks like this:
"see_more": "/discover/categories/food?page=75&ref=category&seed=2390176"
},
{
There are thousands of these instances in these files, so it would take a very long time to do it manually. Note that the url in the "see more" line changes.
If you need more information, please let me know. Thank you.
EDIT:
I figured this out, sort of. I recorded a macro (search for "see_more", move to the next line, add a comma) in TextPad and ran it to the end of the file. Pretty easy and fast, but I doubt this would work in anything much more complex.
json windows text replace editor
json windows text replace editor
edited Dec 30 '18 at 1:26
user8229029
asked Dec 30 '18 at 0:46
user8229029user8229029
526
526
Is the}
always on it's own line? Do you only want to change}
to},
if"see_more":
exists? Or just any}
that exists in the document?
– John Kens
Dec 30 '18 at 1:01
Thank you for the reply, but I figured it out using a TextPad macro.
– user8229029
Dec 30 '18 at 1:26
add a comment |
Is the}
always on it's own line? Do you only want to change}
to},
if"see_more":
exists? Or just any}
that exists in the document?
– John Kens
Dec 30 '18 at 1:01
Thank you for the reply, but I figured it out using a TextPad macro.
– user8229029
Dec 30 '18 at 1:26
Is the
}
always on it's own line? Do you only want to change }
to },
if "see_more":
exists? Or just any }
that exists in the document?– John Kens
Dec 30 '18 at 1:01
Is the
}
always on it's own line? Do you only want to change }
to },
if "see_more":
exists? Or just any }
that exists in the document?– John Kens
Dec 30 '18 at 1:01
Thank you for the reply, but I figured it out using a TextPad macro.
– user8229029
Dec 30 '18 at 1:26
Thank you for the reply, but I figured it out using a TextPad macro.
– user8229029
Dec 30 '18 at 1:26
add a comment |
1 Answer
1
active
oldest
votes
In UltraEdit a Perl regular expression replace all can do that.
Search string: (?s)see_more.+?}K(s*)(?={)
Replace string: ,1
Explanation for search expression:
(?s)
... flag to match also newline characters with dot.
see_more
... this string must be found.
.+?
... any character (including newline characters) one or more times non-greedy.
}
... the previous expression stops matching characters on finding character }
being escaped with a backslash to be interpreted as literal character. Of course {
should not exist in a string value as otherwise this search expression does not work as expected. But it looks like this limitation is no problem for this task.
K
... resets the start location of $0
to the current text position: in other words everything to the left of K
is "kept back" and does not form part of the regular expression match.
(s*)
... find any whitespace character 0 or more times and mark the found whitespaces for back-referencing.
(?={)
... positive lookahead to check if next character is a left brace being escaped with a backslash to be interpreted as literal character.
The replace strings consists of the comma to insert, and back-references the whitespaces between }
and {
to keep them unmodified.
Another solution working most likely in all text editors with Perl compatible regular expression support including UltraEdit:
Search string: (see_more[sS]+?})(s*)(?={)
Replace string: $1,$2
The dot is replaced by [sS]
to match any whitespace OR any non-whitespace character which means also any character including newline characters.
The string matched from see_more
to first found }
is marked and back-referenced in replace string with $1
to keep this part of found string unmodified. The whitespaces between }
and {
matched by s*
in a second marking group defined with (
and )
are referenced here with $2
to keep them also on inserting the comma between.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53974472%2ffind-matching-text-and-replacing-next-line-windows-10%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In UltraEdit a Perl regular expression replace all can do that.
Search string: (?s)see_more.+?}K(s*)(?={)
Replace string: ,1
Explanation for search expression:
(?s)
... flag to match also newline characters with dot.
see_more
... this string must be found.
.+?
... any character (including newline characters) one or more times non-greedy.
}
... the previous expression stops matching characters on finding character }
being escaped with a backslash to be interpreted as literal character. Of course {
should not exist in a string value as otherwise this search expression does not work as expected. But it looks like this limitation is no problem for this task.
K
... resets the start location of $0
to the current text position: in other words everything to the left of K
is "kept back" and does not form part of the regular expression match.
(s*)
... find any whitespace character 0 or more times and mark the found whitespaces for back-referencing.
(?={)
... positive lookahead to check if next character is a left brace being escaped with a backslash to be interpreted as literal character.
The replace strings consists of the comma to insert, and back-references the whitespaces between }
and {
to keep them unmodified.
Another solution working most likely in all text editors with Perl compatible regular expression support including UltraEdit:
Search string: (see_more[sS]+?})(s*)(?={)
Replace string: $1,$2
The dot is replaced by [sS]
to match any whitespace OR any non-whitespace character which means also any character including newline characters.
The string matched from see_more
to first found }
is marked and back-referenced in replace string with $1
to keep this part of found string unmodified. The whitespaces between }
and {
matched by s*
in a second marking group defined with (
and )
are referenced here with $2
to keep them also on inserting the comma between.
add a comment |
In UltraEdit a Perl regular expression replace all can do that.
Search string: (?s)see_more.+?}K(s*)(?={)
Replace string: ,1
Explanation for search expression:
(?s)
... flag to match also newline characters with dot.
see_more
... this string must be found.
.+?
... any character (including newline characters) one or more times non-greedy.
}
... the previous expression stops matching characters on finding character }
being escaped with a backslash to be interpreted as literal character. Of course {
should not exist in a string value as otherwise this search expression does not work as expected. But it looks like this limitation is no problem for this task.
K
... resets the start location of $0
to the current text position: in other words everything to the left of K
is "kept back" and does not form part of the regular expression match.
(s*)
... find any whitespace character 0 or more times and mark the found whitespaces for back-referencing.
(?={)
... positive lookahead to check if next character is a left brace being escaped with a backslash to be interpreted as literal character.
The replace strings consists of the comma to insert, and back-references the whitespaces between }
and {
to keep them unmodified.
Another solution working most likely in all text editors with Perl compatible regular expression support including UltraEdit:
Search string: (see_more[sS]+?})(s*)(?={)
Replace string: $1,$2
The dot is replaced by [sS]
to match any whitespace OR any non-whitespace character which means also any character including newline characters.
The string matched from see_more
to first found }
is marked and back-referenced in replace string with $1
to keep this part of found string unmodified. The whitespaces between }
and {
matched by s*
in a second marking group defined with (
and )
are referenced here with $2
to keep them also on inserting the comma between.
add a comment |
In UltraEdit a Perl regular expression replace all can do that.
Search string: (?s)see_more.+?}K(s*)(?={)
Replace string: ,1
Explanation for search expression:
(?s)
... flag to match also newline characters with dot.
see_more
... this string must be found.
.+?
... any character (including newline characters) one or more times non-greedy.
}
... the previous expression stops matching characters on finding character }
being escaped with a backslash to be interpreted as literal character. Of course {
should not exist in a string value as otherwise this search expression does not work as expected. But it looks like this limitation is no problem for this task.
K
... resets the start location of $0
to the current text position: in other words everything to the left of K
is "kept back" and does not form part of the regular expression match.
(s*)
... find any whitespace character 0 or more times and mark the found whitespaces for back-referencing.
(?={)
... positive lookahead to check if next character is a left brace being escaped with a backslash to be interpreted as literal character.
The replace strings consists of the comma to insert, and back-references the whitespaces between }
and {
to keep them unmodified.
Another solution working most likely in all text editors with Perl compatible regular expression support including UltraEdit:
Search string: (see_more[sS]+?})(s*)(?={)
Replace string: $1,$2
The dot is replaced by [sS]
to match any whitespace OR any non-whitespace character which means also any character including newline characters.
The string matched from see_more
to first found }
is marked and back-referenced in replace string with $1
to keep this part of found string unmodified. The whitespaces between }
and {
matched by s*
in a second marking group defined with (
and )
are referenced here with $2
to keep them also on inserting the comma between.
In UltraEdit a Perl regular expression replace all can do that.
Search string: (?s)see_more.+?}K(s*)(?={)
Replace string: ,1
Explanation for search expression:
(?s)
... flag to match also newline characters with dot.
see_more
... this string must be found.
.+?
... any character (including newline characters) one or more times non-greedy.
}
... the previous expression stops matching characters on finding character }
being escaped with a backslash to be interpreted as literal character. Of course {
should not exist in a string value as otherwise this search expression does not work as expected. But it looks like this limitation is no problem for this task.
K
... resets the start location of $0
to the current text position: in other words everything to the left of K
is "kept back" and does not form part of the regular expression match.
(s*)
... find any whitespace character 0 or more times and mark the found whitespaces for back-referencing.
(?={)
... positive lookahead to check if next character is a left brace being escaped with a backslash to be interpreted as literal character.
The replace strings consists of the comma to insert, and back-references the whitespaces between }
and {
to keep them unmodified.
Another solution working most likely in all text editors with Perl compatible regular expression support including UltraEdit:
Search string: (see_more[sS]+?})(s*)(?={)
Replace string: $1,$2
The dot is replaced by [sS]
to match any whitespace OR any non-whitespace character which means also any character including newline characters.
The string matched from see_more
to first found }
is marked and back-referenced in replace string with $1
to keep this part of found string unmodified. The whitespaces between }
and {
matched by s*
in a second marking group defined with (
and )
are referenced here with $2
to keep them also on inserting the comma between.
answered Jan 4 at 18:03


MofiMofi
28.1k83777
28.1k83777
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53974472%2ffind-matching-text-and-replacing-next-line-windows-10%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
PMJBm9C2yER,44C s,1nr1u
Is the
}
always on it's own line? Do you only want to change}
to},
if"see_more":
exists? Or just any}
that exists in the document?– John Kens
Dec 30 '18 at 1:01
Thank you for the reply, but I figured it out using a TextPad macro.
– user8229029
Dec 30 '18 at 1:26