Questions tagged [replace]

Replacing is the action of searching a string for a sub-string and replacing it with a different string.

Replacing is the action of searching a string (the haystack) for a sub-string (the needle) and replacing it with a different string.

for example, replacing all 'l' within 'Hello' with 'y', would result in 'Heyyo'.

27903 questions
6
votes
1 answer

MySQL Regex Search and replace

I would like to remove height property from all my images in my database. Their markup is as follows: I was going to do something like this: UPDATE jos_content SET introtext = REPLACE(introtext,…
Jinx
  • 857
  • 2
  • 14
  • 28
6
votes
3 answers

Replacing one item in a list with two items

What is the simplest method for replacing one item in a list with two? So: list=['t' , 'r', 'g', 'h', 'k'] if I wanted to replace 'r' with 'a' and 'b': list = ['t' , 'a' , 'b', 'g', 'h', 'k']
Jasmine078
  • 389
  • 2
  • 4
  • 16
6
votes
5 answers

Replacing all GUIDs in a file with new GUIDs from the command line

I have a file containing a large number of occurrences of the string Guid="GUID HERE" (where GUID HERE is a unique GUID at each occurrence) and I want to replace every existing GUID with a new unique GUID. This is on a Windows development machine,…
user197015
6
votes
3 answers

Why can't sed replace 0x24 byte in binary file?

I'm want to replace some bytes in binary file to another. Created sample (6 bytes long) file via echo -ne '\x8f\x15\x42\x02\x24\xc2' > test Then tried to replace bytes \x15\x42\x02 to \x12\x12\x02 via sed: sed 's \x15\x42\x02 \x12\x12\x02 g' test…
S-trace
  • 75
  • 1
  • 1
  • 6
6
votes
2 answers

Notepad++ File Filters

I was wondering if it was possible to list an exclusion within the file filters in the "find in files" functionality of Notepad++. For example the following will replace Dog with Cat in all files. Find what: Dog Replace with: Cat Filters: *.* What I…
Denis Sadowski
  • 3,035
  • 5
  • 24
  • 26
6
votes
2 answers

How to find and replace multiple lines in text file?

I am running Python 2.7. I have three text files: data.txt, find.txt, and replace.txt. Now, find.txt contains several lines that I want to search for in data.txt and replace that section with the content in replace.txt. Here is a simple…
noblerare
  • 10,277
  • 23
  • 78
  • 140
6
votes
1 answer

How to find and replace in the bookmarked lines in Notepad++

I have a problem about how to find and replace in the bookmarked lines in Notepad++. For example my line is .... So I bookmark the lines that have , how I could find and replace in those lines?
SevenT
  • 83
  • 1
  • 4
6
votes
2 answers

How do u replace a string that's not inside a specific div?

I have this html:
This following word is not ok but all the other words are ok
And using this jquery I'm trying to replace the word ok with cool, as long as the word ok is not inside the span #notOk.…
Squirrl
  • 4,909
  • 9
  • 47
  • 85
6
votes
2 answers

Matching one-line JavaScript comments (//) with re

I'd like to filter out (mostly one-line) comments from (mostly valid) JavaScript using python's re module. For example: // this is a comment var x = 2 // and this is a comment too var url = "http://www.google.com/" // and "this" too url += 'but //…
Attila O.
  • 15,659
  • 11
  • 54
  • 84
6
votes
2 answers

How to use different separators (/ , |) in a regular expression

Modifying a Perl script, i got this: $var =~ s,/$,,; it seems to be a regex pattern, but i was expecting to found "/" (or "|") instead of "," as separator. So the question is: when and why one should use in a regex pattern "/" or "|" or ","?
Filippo Lauria
  • 1,965
  • 14
  • 20
6
votes
1 answer

Google Apps Script Make text a clickable URL using replaceText()

I have this code that opens the file and replaces a string using replaceText. var url = 'http://www.test.com'; var doc = DocumentApp.openById(file.getId()); doc.replaceText("<>", url); doc.saveAndClose(); When I open the doc, the…
Employee
  • 2,231
  • 3
  • 33
  • 60
6
votes
3 answers

Replace empty values with value from other column in a dataframe

In one column of my dataframe I have some empty cells. The data looks like this: yymmdd lat lon mag depth knmilocatie baglocatie tijd 19861226 52.992 6.548 2.8 1.0 Assen Assen 74751 19871214 52.928 6.552 2.5 1.5 …
Jaap
  • 81,064
  • 34
  • 182
  • 193
6
votes
4 answers

Search and replace string in txt file in c++

I want to find a string in a file and replace it with user input. Here is my rough code. #include #include #include int main(){ istream readFile("test.txt"); string readout, search, …
Axeem
  • 670
  • 4
  • 16
  • 26
6
votes
2 answers

Remove certain characters from string

I want to create a program that gives the number of characters, words, etc... in a user-inputted string. To get the word count I need to remove all the periods and commas form a string. So far I have this: import javax.swing.JOptionPane; public…
f3d0r
  • 541
  • 3
  • 12
  • 27
6
votes
3 answers

javascript replace globally with array

You can use array for replacement: var array = {"from1":"to1", "from2":"to2"} for (var val in array) text = text.replace(array, array[val]); But what if you need to replace globally, ie text = text.replace(/from/g, "to"); Array is pretty big,…
Qiao
  • 16,565
  • 29
  • 90
  • 117