tagged [replace]
Adding backslashes without escaping
Adding backslashes without escaping I need to escape a `&` (ampersand) character in a string. The problem is whenever I `string = string.replace ('&', '\&')` the result is `'\\&'`. An extra backslash ...
Remove specific characters from a string in Python
Remove specific characters from a string in Python I'm trying to remove specific characters from a string using Python. This is the code I'm using right now. Unfortunately it appears to do nothing to ...
- Modified
- 30 May at 12:32
Fastest way to replace multiple strings in a huge string
Fastest way to replace multiple strings in a huge string I'm looking for the fastest way to replace multiple (~500) substrings of a big (~1mb) string. Whatever I have tried it seems that String.Replac...
- Modified
- 21 Apr at 06:15
Replace the string of special characters in C#
Replace the string of special characters in C# My requirement is: > I have to replace some special characters like * ' " , _ & # ^ @ with `string.Empty`, and I have to replace blank spaces with `-`. T...
How can I perform a str_replace in JavaScript, replacing text in JavaScript?
How can I perform a str_replace in JavaScript, replacing text in JavaScript? I want to use `str_replace` or its similar alternative to replace some text in JavaScript. should give ``` this is some sam...
- Modified
- 15 Mar at 12:25
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...
- Modified
- 11 Dec at 07:58
What function is to replace a substring from a string in C?
What function is to replace a substring from a string in C? Given a (`char *`) string, I want to find all occurrences of a substring and replace them with an alternate string. I do not see any simple ...
C# replace string in string
C# replace string in string Is it possible to replace a substring in a string without assigning a return value? I have a string: And I want to replace the substring `[REPLACE]` with something else: Th...
C# string replace
C# string replace I want to replace `","` with a `;` in my string. For example: Change > "Text","Text","Text", to this: > "Text;Text;Text", I've been trying the `line.replace( ... , ... )`, but can't ...
- Modified
- 19 Jul at 17:45
Regex replace multiple groups
Regex replace multiple groups I would like to use regular expressions to replace multiple groups with corresponding replacement string. Replacement table: - `"&"``"__amp"`- `"#"``"__hsh"`- `"1"``"5"`-...
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
How does MatchEvaluator in Regex.Replace work?
How does MatchEvaluator in Regex.Replace work? This is the input string `23x * y34x2`. I want to insert `" * "` (star surrounded by whitespaces) after every number followed by letter, and after every ...
- Modified
- 21 Jan at 10:0
Strip Leading and Trailing Spaces From Java String
Strip Leading and Trailing Spaces From Java String Is there a convenience method to strip any leading or trailing spaces from a Java String? Something like: Result: `myString.replace(" ","")` would re...
Best way to replace multiple characters in a string?
Best way to replace multiple characters in a string? I need to replace some characters as follows: `&` ➔ `\&`, `#` ➔ `\#`, ... I coded as follows, but I guess there should be some better way. Any hint...
String replace method is not replacing characters
String replace method is not replacing characters I have a sentence that is passed in as a string and I am doing a replace on the word "and" and I want to replace it with " ". And it's not replacing t...
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...
- Modified
- 10 Jul at 10:32
Transform title into dashed URL-friendly string
Transform title into dashed URL-friendly string I would like to write a C# method that would transform any title into a URL friendly string, similar to what Stack Overflow does: - - - I'm thinking of ...
Find and replace with sed in directory and sub directories
Find and replace with sed in directory and sub directories I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site: But it doesn't go through su...
- Modified
- 9 Mar at 15:51
Replace specific characters within strings
Replace specific characters within strings I would like to remove specific characters from strings within a vector, similar to the feature in Excel. Here are the data I start with: ``` group
- Modified
- 21 Feb at 00:14
Replace all occurences of a string from a string array
Replace all occurences of a string from a string array I have a string array like: I would like to replace all ones with zero at once. Then items should be: `{"zero","two","three","zero","two","zero"}...
Fastest method to replace all instances of a character in a string
Fastest method to replace all instances of a character in a string What is the fastest way to replace all instances of a string/character in a string in JavaScript? A `while`, a `for`-loop, a regular ...
- Modified
- 5 Sep at 16:43
Find and replace - Add carriage return OR Newline
Find and replace - Add carriage return OR Newline In the case of following string to be parsed. I want to replace the `~~?` with a `carriage return` Replacing with `\n` just adds the string `"\n"` How...
- Modified
- 25 Jul at 15:8