Notepad++, replace “x” with a value from a listFind and Replace several several different values all at...
Is it possible to run Internet Explorer on OS X El Capitan?
Is it inappropriate for a student to attend their mentor's dissertation defense?
Should I tell management that I intend to leave due to bad software development practices?
Why is Collection not simply treated as Collection<?>
Is the Joker left-handed?
How much of data wrangling is a data scientist's job?
Would Slavery Reparations be considered Bills of Attainder and hence Illegal?
Why doesn't H₄O²⁺ exist?
Why is the 'in' operator throwing an error with a string literal instead of logging false?
Today is the Center
Doing something right before you need it - expression for this?
Fully-Firstable Anagram Sets
What is the most common color to indicate the input-field is disabled?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Why are electrically insulating heatsinks so rare? Is it just cost?
Were any external disk drives stacked vertically?
How do conventional missiles fly?
Why does Kotter return in Welcome Back Kotter
How to model explosives?
Facing a paradox: Earnshaw's theorem in one dimension
Is it unprofessional to ask if a job posting on GlassDoor is real?
Infinite Abelian subgroup of infinite non Abelian group example
Stopping power of mountain vs road bike
Brothers & sisters
Notepad++, replace “x” with a value from a list
Find and Replace several several different values all at onceHow do I add “input” to my macro, to replace text in Notepad++?Regex replace with Notepad++Remove CR LF for all lines that are not followed by a specific numberNotepad ++ find and replace issueNotepad++ replace a random value with blankNotepad++ RegEx Find and replace with 2 variablesHow to remove all top level domain names using Notepad++Replace Multiple Instances of Same Line with Only One Instance?Find/Replace with changing value?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Basically what the title says, let me make an example.
this=X
that=XXX
those=XX
I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:
this=2
that=312
those=32
Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.
notepad++
add a comment |
Basically what the title says, let me make an example.
this=X
that=XXX
those=XX
I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:
this=2
that=312
those=32
Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.
notepad++
add a comment |
Basically what the title says, let me make an example.
this=X
that=XXX
those=XX
I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:
this=2
that=312
those=32
Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.
notepad++
Basically what the title says, let me make an example.
this=X
that=XXX
those=XX
I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:
this=2
that=312
those=32
Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.
notepad++
notepad++
edited Jul 30 '16 at 17:23
DavidPostill♦
108k27235270
108k27235270
asked Jul 30 '16 at 17:06
AnotheroneAnotherone
62
62
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I want to randomly replace X with a value from a list
This is not possible using built in Notepad++ functionality.
You could write a script to do it.
There is a python script plugin for Notepad++:
Python Script for Notepad++
- Full programmatic access to Notepad++ features and menus
- Full programmatic access to all of Scintilla features
- Call other plugin menu items
- Assign menu items, shortcuts and toolbar icons to scripts
- Process Notepad++ and Scintilla events, direct from a Python script
- Python console built-in
- Full regular expression support for search and replace - script Python regular expression replaces
- Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window
- Full documentation for all the objects and methods
Source Python Script for Notepad++
add a comment |
As DavidPostill wrote, this is not possible via Notepad++.
However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:
- first, replace
XXX
, becauseXXX
is not part ofX
orXX
(reversed,X
is a part ofXXX
, and if you replaceX
first, e. g. withfoo
, then you will end up withfoo
,foofoo
,foofoofoo
.) - then replace
XX
at the end, replace
X
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: XXX
replace: foo
test1=X
test2=XX
test3=foo
ctrl-h
search: XX
replace: bar
test1=X
test2=bar
test3=foo
and so on.
Counter example:
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: X
replace: foo
test1=foo
test2=foofoo
test3=foofoofoo
Alternatives
Cygwin
the first alternative which comes to my mind is Cygwin
because it's installed on my PC anyway.
Fire up Cygwin and use perl
, sed
or awk
for replacement.
Powershell
As stated here, you could use some PowerShell script along the lines of
(Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt
Batch
As stated here, you can also use Batch scripts, e. g.
@echo off &setlocal
setlocal enabledelayedexpansion
set "search=%1"
set "replace=%2"
set "textfile=Input.txt"
set "newfile=Output.txt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
set "line=!line:%search%=%replace%!"
echo(!line!
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
endlocal
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1106872%2fnotepad-replace-x-with-a-value-from-a-list%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I want to randomly replace X with a value from a list
This is not possible using built in Notepad++ functionality.
You could write a script to do it.
There is a python script plugin for Notepad++:
Python Script for Notepad++
- Full programmatic access to Notepad++ features and menus
- Full programmatic access to all of Scintilla features
- Call other plugin menu items
- Assign menu items, shortcuts and toolbar icons to scripts
- Process Notepad++ and Scintilla events, direct from a Python script
- Python console built-in
- Full regular expression support for search and replace - script Python regular expression replaces
- Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window
- Full documentation for all the objects and methods
Source Python Script for Notepad++
add a comment |
I want to randomly replace X with a value from a list
This is not possible using built in Notepad++ functionality.
You could write a script to do it.
There is a python script plugin for Notepad++:
Python Script for Notepad++
- Full programmatic access to Notepad++ features and menus
- Full programmatic access to all of Scintilla features
- Call other plugin menu items
- Assign menu items, shortcuts and toolbar icons to scripts
- Process Notepad++ and Scintilla events, direct from a Python script
- Python console built-in
- Full regular expression support for search and replace - script Python regular expression replaces
- Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window
- Full documentation for all the objects and methods
Source Python Script for Notepad++
add a comment |
I want to randomly replace X with a value from a list
This is not possible using built in Notepad++ functionality.
You could write a script to do it.
There is a python script plugin for Notepad++:
Python Script for Notepad++
- Full programmatic access to Notepad++ features and menus
- Full programmatic access to all of Scintilla features
- Call other plugin menu items
- Assign menu items, shortcuts and toolbar icons to scripts
- Process Notepad++ and Scintilla events, direct from a Python script
- Python console built-in
- Full regular expression support for search and replace - script Python regular expression replaces
- Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window
- Full documentation for all the objects and methods
Source Python Script for Notepad++
I want to randomly replace X with a value from a list
This is not possible using built in Notepad++ functionality.
You could write a script to do it.
There is a python script plugin for Notepad++:
Python Script for Notepad++
- Full programmatic access to Notepad++ features and menus
- Full programmatic access to all of Scintilla features
- Call other plugin menu items
- Assign menu items, shortcuts and toolbar icons to scripts
- Process Notepad++ and Scintilla events, direct from a Python script
- Python console built-in
- Full regular expression support for search and replace - script Python regular expression replaces
- Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window
- Full documentation for all the objects and methods
Source Python Script for Notepad++
answered Jul 30 '16 at 17:22
DavidPostill♦DavidPostill
108k27235270
108k27235270
add a comment |
add a comment |
As DavidPostill wrote, this is not possible via Notepad++.
However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:
- first, replace
XXX
, becauseXXX
is not part ofX
orXX
(reversed,X
is a part ofXXX
, and if you replaceX
first, e. g. withfoo
, then you will end up withfoo
,foofoo
,foofoofoo
.) - then replace
XX
at the end, replace
X
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: XXX
replace: foo
test1=X
test2=XX
test3=foo
ctrl-h
search: XX
replace: bar
test1=X
test2=bar
test3=foo
and so on.
Counter example:
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: X
replace: foo
test1=foo
test2=foofoo
test3=foofoofoo
Alternatives
Cygwin
the first alternative which comes to my mind is Cygwin
because it's installed on my PC anyway.
Fire up Cygwin and use perl
, sed
or awk
for replacement.
Powershell
As stated here, you could use some PowerShell script along the lines of
(Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt
Batch
As stated here, you can also use Batch scripts, e. g.
@echo off &setlocal
setlocal enabledelayedexpansion
set "search=%1"
set "replace=%2"
set "textfile=Input.txt"
set "newfile=Output.txt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
set "line=!line:%search%=%replace%!"
echo(!line!
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
endlocal
add a comment |
As DavidPostill wrote, this is not possible via Notepad++.
However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:
- first, replace
XXX
, becauseXXX
is not part ofX
orXX
(reversed,X
is a part ofXXX
, and if you replaceX
first, e. g. withfoo
, then you will end up withfoo
,foofoo
,foofoofoo
.) - then replace
XX
at the end, replace
X
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: XXX
replace: foo
test1=X
test2=XX
test3=foo
ctrl-h
search: XX
replace: bar
test1=X
test2=bar
test3=foo
and so on.
Counter example:
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: X
replace: foo
test1=foo
test2=foofoo
test3=foofoofoo
Alternatives
Cygwin
the first alternative which comes to my mind is Cygwin
because it's installed on my PC anyway.
Fire up Cygwin and use perl
, sed
or awk
for replacement.
Powershell
As stated here, you could use some PowerShell script along the lines of
(Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt
Batch
As stated here, you can also use Batch scripts, e. g.
@echo off &setlocal
setlocal enabledelayedexpansion
set "search=%1"
set "replace=%2"
set "textfile=Input.txt"
set "newfile=Output.txt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
set "line=!line:%search%=%replace%!"
echo(!line!
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
endlocal
add a comment |
As DavidPostill wrote, this is not possible via Notepad++.
However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:
- first, replace
XXX
, becauseXXX
is not part ofX
orXX
(reversed,X
is a part ofXXX
, and if you replaceX
first, e. g. withfoo
, then you will end up withfoo
,foofoo
,foofoofoo
.) - then replace
XX
at the end, replace
X
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: XXX
replace: foo
test1=X
test2=XX
test3=foo
ctrl-h
search: XX
replace: bar
test1=X
test2=bar
test3=foo
and so on.
Counter example:
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: X
replace: foo
test1=foo
test2=foofoo
test3=foofoofoo
Alternatives
Cygwin
the first alternative which comes to my mind is Cygwin
because it's installed on my PC anyway.
Fire up Cygwin and use perl
, sed
or awk
for replacement.
Powershell
As stated here, you could use some PowerShell script along the lines of
(Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt
Batch
As stated here, you can also use Batch scripts, e. g.
@echo off &setlocal
setlocal enabledelayedexpansion
set "search=%1"
set "replace=%2"
set "textfile=Input.txt"
set "newfile=Output.txt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
set "line=!line:%search%=%replace%!"
echo(!line!
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
endlocal
As DavidPostill wrote, this is not possible via Notepad++.
However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:
- first, replace
XXX
, becauseXXX
is not part ofX
orXX
(reversed,X
is a part ofXXX
, and if you replaceX
first, e. g. withfoo
, then you will end up withfoo
,foofoo
,foofoofoo
.) - then replace
XX
at the end, replace
X
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: XXX
replace: foo
test1=X
test2=XX
test3=foo
ctrl-h
search: XX
replace: bar
test1=X
test2=bar
test3=foo
and so on.
Counter example:
test1=X
test2=XX
test3=XXX
ctrl-a, ctrl-h
search: X
replace: foo
test1=foo
test2=foofoo
test3=foofoofoo
Alternatives
Cygwin
the first alternative which comes to my mind is Cygwin
because it's installed on my PC anyway.
Fire up Cygwin and use perl
, sed
or awk
for replacement.
Powershell
As stated here, you could use some PowerShell script along the lines of
(Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt
Batch
As stated here, you can also use Batch scripts, e. g.
@echo off &setlocal
setlocal enabledelayedexpansion
set "search=%1"
set "replace=%2"
set "textfile=Input.txt"
set "newfile=Output.txt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
set "line=!line:%search%=%replace%!"
echo(!line!
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
endlocal
edited May 23 '17 at 12:41
Community♦
1
1
answered Jul 31 '16 at 6:49
stuejastueja
5011311
5011311
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1106872%2fnotepad-replace-x-with-a-value-from-a-list%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