tagged [replace]

How to use operator '-replace' in PowerShell to replace strings of texts with special characters and replace successfully

How to use operator '-replace' in PowerShell to replace strings of texts with special characters and replace successfully I have a script where I am basically doing a find and replace on several strin...

13 Jul at 13:41

String replace a Backslash

String replace a Backslash How can I do a string replace of a back slash. In the above String I want to replace "\/" with a "/"; I get the Source String from a third party, therefore I have control ov...

8 Apr at 14:18

JavaScript: replace last occurrence of text in a string

JavaScript: replace last occurrence of text in a string See my code snippet below: ``` var list = ['one', 'two', 'three', 'four']; var str = 'one two, one three, one four, one'; for ( var i = 0; i

25 Apr at 17:4

Regular expression search replace in Sublime Text 2

Regular expression search replace in Sublime Text 2 I'm looking to do search replace with regular expressions in Sublime Text 2. The [documentation on this](http://docs.sublimetext.info/en/latest/sear...

25 May at 15:33

how to use a regular expression to extract json fields?

how to use a regular expression to extract json fields? Beginner RegExp question. I have lines of JSON in a textfile, each with slightly different Fields, but there are 3 fields I want to extract for ...

13 May at 13:3

TypeError: 'float' object is not subscriptable

TypeError: 'float' object is not subscriptable Basically, I have an input that a user will put a number values (float input) into, then it will set all of these aforementioned list indexes to that va

6 Feb at 10:45

JavaScript replace/regex

JavaScript replace/regex Given this function: How do I make `this.markup.replace()` replace globally? Here's the problem. If I use it like this: ``` alert(

30 Jun at 15:58

How do I replace a character in a string in Java?

How do I replace a character in a string in Java? Using Java, I want to go through the lines of a text and replace all ampersand symbols (`&`) with the XML entity reference `&`. I scan the lines o...

5 Aug at 17:8

Regex : how to get words from a string (C#)

Regex : how to get words from a string (C#) My input consists of user-posted strings. What I want to do is create a dictionary with words, and how often they’ve been used. This means I want to parse a...

11 Oct at 19:42

Finding and replacing elements in a list

Finding and replacing elements in a list I have to search through a list and replace all occurrences of one element with another. So far my attempts in code are getting me nowhere, what is the best wa...

19 Aug at 23:8

PHP remove commas from numeric strings

PHP remove commas from numeric strings In PHP, I have an array of variables that are ALL strings. Some of the values stored are numeric strings with commas. What I need: A way to trim the commas from...

7 Jun at 15:42

Replace and overwrite instead of appending

Replace and overwrite instead of appending I have the following code: where I'd like to replace the old content that's in the file with the new content

16 Feb at 19:44

How to swap text based on patterns at once with sed?

How to swap text based on patterns at once with sed? Suppose I have 'abbc' string and I want to replace: - - If I try two replaces the result is not what I want: So what sed command can I use to repla...

31 Jan at 02:55

UPDATE and REPLACE part of a string

UPDATE and REPLACE part of a string I've got a table with two columns, `ID` and `Value`. I want to change a part of some strings in the second column. Example of Table: Now the `123\` in the `Valu

string IndexOf and Replace

string IndexOf and Replace I have just faced this problem today and wonder if someone has any idea about why does this test may fail (depending on culture). The aim is to check if the test text contai...

7 Feb at 16:15

How do I find and replace all occurrences (in all files) in Visual Studio Code?

How do I find and replace all occurrences (in all files) in Visual Studio Code? I can't figure out how to find and replace all occurrences of a word in different files using Visual Studio Code version...

10 Jul at 10:32

How to replace the text between two characters in c#

How to replace the text between two characters in c# I am bit confused writing the regex for finding the Text between the two delimiters and replace the text with another text in c#,how to replace? I ...

20 Dec at 10:51

String.Replace() vs. StringBuilder.Replace()

String.Replace() vs. StringBuilder.Replace() I have a string in which I need to replace markers with values from a dictionary. It has to be as efficient as possible. Doing a loop with a string.replace...

29 Jun at 17:15

Find and Replace Inside a Text File from a Bash Command

Find and Replace Inside a Text File from a Bash Command What's the simplest way to do a find and replace for a given input string, say `abc`, and replace with another string, say `XYZ` in file `/tmp/f...

15 Jan at 11:47

C# Replacing part of string by start and end position

C# Replacing part of string by start and end position I have a string and I want to replace a part of it. The tricky part is that that I can't use Regex.replace, because I only know the start and end ...

4 Sep at 20:9

string replace using a List<string>

string replace using a List I have a List of words I want to ignore like this one : For a given string, say `"14th Avenue North"` I want to be able to remove the "North" part, so basically a function ...

14 Sep at 19:58

Is there an alternative to string.Replace that is case-insensitive?

Is there an alternative to string.Replace that is case-insensitive? I need to search a string and replace all occurrences of `%FirstName%` and `%PolicyAmount%` with a value pulled from a database. The...

9 Aug at 03:53

How can I remove a character from a string using JavaScript?

How can I remove a character from a string using JavaScript? I am so close to getting this, but it just isn't right. All I would like to do is remove the character `r` from a string. The problem is, t...

11 Dec at 07:58

How to replace NaN value with zero in a huge data frame?

How to replace NaN value with zero in a huge data frame? I tried to replace `NaN` values with zeros using the following script: The NaN value was showing to be zero but when I typed in the name of the...

9 Aug at 08:42

Count regex replaces (C#)

Count regex replaces (C#) Is there a way to count the number of replacements a Regex.Replace call makes? E.g. for `Regex.Replace("aaa", "a", "b");` I want to get the number 3 out (result is `"bbb"`); ...

14 Feb at 16:4