Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I want to do a "bulk" search and replace (notepad++) in many text files but that search and replace has to be "intelligent" and do the replacement in the following way:
I search for a pattern "source" and want to replace with "target". The search for "source" should be without check upper/lower - so the search should find "Source", "source" or "SOURCE"
The automatic replacement then should be done in the following way:
"Source" -> "Target"
"source" -> "target"
"SOURCE" -> "TARGET"
Is that possible? And if yes, how to do it?
Every programming language is case sensitive like python, C etc., so:
with open("nameofdocu.txt") as f:
data = f.read()
change = input("Type a word you want to replace")
if(change == Source):
data.replace(Source,Target)
elif(change == source):
data.replace(source,target)
elif(change == SOURCE)
data.replace(SOURCE,TARGET)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have big markdown file. Is there any way to change /foo in my url by /bla. That is, I want to replace
[text](/foo/some-long-url/a.html)
for
[text](/bla/some-long-url/a.html)
(all ocurrences).
I know I could compile markdown file to html and use html parsers (like BeautifulSoup) to do that. But I want to do that, on the source file.
Prefered python or shell solutions.
I mean you can always replace "/foo" to "/bla" directly in the source using sed?
sed 's/\/foo/\/bla/' source.md >> destination.md
If it catches anything unwanted, you can just tweak the regular expression a bit to be more specific.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I want to print the line which has below value in my text file(ex: file.txt).
I have tried multiple ways but no luck. Can someone please help me the right command.
selector="((Source IN ('VPS','VPSLegacy')) OR (JMS_TIBCO_SENDER='rig'))"
Please note that i need to use entire above value to check in the file.
The easiest way to assign a literal (potentially containing quotes or other shell syntax) to a variable, even though it comes with a performance penalty, is to use a quoted heredoc:
content=$(cat <<'EOF'
selector="((Source IN ('VPS','VPSLegacy')) OR (JMS_TIBCO_SENDER='rig'))"
EOF
)
echo "Value is: <$content>"
...correctly emits as output:
Value is: <selector="((Source IN ('VPS','VPSLegacy')) OR (JMS_TIBCO_SENDER='rig'))">
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a text file with thousands of this code below which is almost identical apart from it has a different id number. I want to find and delete all instances of this code but I do not know how to do this as find and replace requires the text to be identical. How can I do this? And what text editor on a mac can do this? Eg:
<br><a target='_blank' href='http://example.com/home/details/indexid/1101372'>Read More</a>
<br><a target='_blank' href='http://example.com/home/details/indexid/1101337'>Read More</a>
Use any text editor that allows you regular expression replace. E.g. Sublime Text.
Then do replace with <br><a target='_blank' href='http:\/\/example\.com\/home\/details\/indexid\/\d+'>Read More<\/a>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to remove all comments from the following code snippet using vim. Please help me in this.
int main()
{
Computer compute;
// To create an 'instance' of the class, simply treat it like you would
// a structure. (An instance is simply when you create an actual object
// from the class, as opposed to having the definition of the class)
compute.setspeed ( 100 );
// To call functions in the class, you put the name of the instance,
// a period, and then the function name.
cout<< compute.readspeed();
// See above note.
}
:g/<Pattern>/d
It will delete all lines which match the <Pattern>. e.g.
:g/\s*\/\//d
will delete all lines which has first two non-whitespace character as //.
There is several way to do this.
The easiest is probably to use a plugin like NERDCommenter http://www.vim.org/scripts/script.php?script_id=1218
If you don't want to install things, then you can use the visual mode:
- Ctrl + V to get into column visual mode
- Select the //
- then x
You can also use a macro with qa then delete the // of the first line, close the recording with q, and replay the macro with #a.
Finally, if you are a regex fan, then you can do this : :g/\s*\/\//d
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm developing simple game that load map form txt which format something like this:
# Map file for tile-based game
# (Lines that start with '#' are comments)
# The tiles are:
# (Space) Empty tile
# A..Z Tiles A through Z
# s Star
# 1 Bad Guy 1
# 2 Bad Guy 2
2 IAJ ssssss 1 1
IABABAELFBABABABABABABABABABABABABABABABABABABABABABABABABABABABJ
LMLMLMCKDLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLMLM
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
Where i can find simple map editor like this? Simple map editor
thx
You're not going to find an existing editor that writes to your specific file format, but tile map editors like Tiled write to a simple file format that is easy for you to parse. Another tile map editor is Mappy.