tagged [replace]
regex string replace
regex string replace I am trying to do a basic string replace using a regex expression, but the answers I have found do not seem to help - they are directly answering each persons unique requirement w...
- Modified
- 4 May at 08:59
How to replace an entire line in a text file by line number
How to replace an entire line in a text file by line number I have a situation where I want a bash script to replace an entire line in a file. The line number is always the same, so that can be a hard...
Replace spaces with dashes and make all letters lower-case
Replace spaces with dashes and make all letters lower-case I need to reformat a string using jQuery or vanilla JavaScript Let’s say we have `"Sonic Free Games"`. I want to convert it to `"sonic-free-g...
- Modified
- 2 Mar at 13:35
Replace CRLF using powershell
Replace CRLF using powershell Here is my powershell script: ``` $original_file ='C:\Users\abc\Desktop\File\abc.txt' (Get-Content $original_file) | Foreach-Object { $_ -replace "'", "2"` -replace '2', ...
- Modified
- 22 Feb at 04:19
Alternative to String.Replace
Alternative to String.Replace So I was writing some code today that basically looks like this: ``` string returnString = s.Replace("!", " ") .Replace("@", " ") .Replace("#", " ") .Re...
How to replace multiple substrings of a string?
How to replace multiple substrings of a string? I would like to use the .replace function to replace multiple strings. I currently have but would like to have something like although that does not fe...
Can I replace groups in Java regex?
Can I replace groups in Java regex? I have this code, and I want to know, if I can replace only groups (not all pattern) in Java regex. Code: ``` //... Pattern p = Pattern.compile("(\\d).*(\\d)"); S...
- Modified
- 21 Nov at 06:45
Replacing escape characters from JSON
Replacing escape characters from JSON I want to replace the "\" character from a JSON string by a empty space. How can I do that?
How to Replace by pattern with Regex in C#
How to Replace by pattern with Regex in C# I have a text, the text contains char sequence which begins with # and ends with ="" characters. Between the # and ="" characters just exists alphanumeric ch...
- Modified
- 24 Oct at 07:20
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...
Replace all values in a matrix <0.1 with 0
Replace all values in a matrix
Is it more or less efficient to perform a check before performing a Replace in C#?
Is it more or less efficient to perform a check before performing a Replace in C#? This is an almost academic question but I'm curious as to its answer. Suppose you have a loop that performs a routine...
Mongodb implications of update versus replace
Mongodb implications of update versus replace I have read [this related question](https://stackoverflow.com/q/35848688/304832), but the one below is different. The mongodb c# driver has a `ReplaceOne`...
Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces Looking for quick, simple way in Java to change this string to something that looks like this wh...
C# Trim() vs replace()
C# Trim() vs replace() In a C# `string` if we want to replace `" "` in a string to `string.empty`, is it fine to use `stringValue.Trim()` or `stringValue.replace(" ", string.empty)`. Both serve the sa...
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...
How to replace a character from a String in SQL?
How to replace a character from a String in SQL? I have 100's of cells in our database which contain `?` instead of `'`. It is possible that this might happen in all rows and columns and in more than ...
JS. How to replace html element with another element/text, represented in string?
JS. How to replace html element with another element/text, represented in string? I have a problem with replacing html elements. For example, here is a table: (it can be div, span, anything) And strin...
- Modified
- 7 Jun at 19:18
Replace any string between quotes
Replace any string between quotes Cannot find a consistent way to replace a random string between quotes with a specific string I want. Any help would be greatly appreciated. should become but also wo...
Regular expression that matches all valid format IPv6 addresses
Regular expression that matches all valid format IPv6 addresses [Regular expression that matches valid IPv6 addresses](https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-i...
Replacing multiple characters in a string, the fastest way?
Replacing multiple characters in a string, the fastest way? I am importing some number of records with multiple `string` fields from an old db to a new db. It seems to be very slow and I suspect it's ...
- Modified
- 23 May at 12:1
Configurable sensitive data masking via log4net
Configurable sensitive data masking via log4net I'm looking at using log4net as my logging framework of choice for a new project starting shortly. One issue that I've run into during prototyping that ...
Remove all multiple spaces in Javascript and replace with single space
Remove all multiple spaces in Javascript and replace with single space How can I automatically replace all instances of multiple spaces, with a single space, in Javascript? I've tried chaining some `s...
- Modified
- 20 May at 17:25
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
- Modified
- 25 Apr at 17:4
Alternative to multiple String.Replaces
Alternative to multiple String.Replaces My code uses `String.Replace` several times in a row: I suspect there's a better and faster way to do it. What would you suggest?
MySQL search and replace some text in a field
MySQL search and replace some text in a field What MySQL query will do a text search and replace in one particular field in a table? I.e. search for `foo` and replace with `bar` so a record with a fie...
php Replacing multiple spaces with a single space
php Replacing multiple spaces with a single space I'm trying to replace multiple spaces with a single space. When I use `ereg_replace`, I get an error about it being deprecated. Is there an identical ...
- Modified
- 15 Sep at 08:7
MySQL string replace
MySQL string replace I have a column containing urls (id, url): I'd like to change the word "updates" to "news". Is it possible to do this with a scrip
Simple excel find and replace for formulas
Simple excel find and replace for formulas I have numerous cells all over the place on a worksheet that look like `=((E9-E8)/E8)`. I want to use the first two values to go into this new formula, `(EXP...
Replace substring with another substring C++
Replace substring with another substring C++ How could I replace a substring in a string with another substring in C++, what functions could I use?
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...
- Modified
- 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 ...
How to find and replace with regex in excel
How to find and replace with regex in excel I have an excel file with 1 column and multiple rows. The rows contain various text, here's an example: I want to replace "texts are *" where * is anything ...
What would be the fastest way to remove Newlines from a String in C#?
What would be the fastest way to remove Newlines from a String in C#? I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline ...
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
- Modified
- 18 Sep at 21:9
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 ...
Replace single backslash with double backslash
Replace single backslash with double backslash It seems simple enough, right? Well, I don't know. Here's the code I'm trying: However, I'm receiving an error, > ArgumentException was unhandled - parsi...
Replace "\\" with "\" in a string in C#
Replace "\\" with "\" in a string in C# I still don't get how to do this. I saw many posts regarding this, but none of the solutions worked for me. I have a string called "a\\b". The result I need is ...
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...
- Modified
- 13 Jul at 13:41
Find and replace words/lines in a file
Find and replace words/lines in a file I have a file (more specifically, a log4j configuration file) and I want to be able to read in the file and pick out certain lines in the code and replace them. ...
How to replace specific values in a oracle database column?
How to replace specific values in a oracle database column? I am looking to replace values in a particular column. For example the following column values should be (replacing `est1` with `rest1`)
Removing double quotes from a string in Java
Removing double quotes from a string in Java How would I remove double quotes from a String? For example: I would expect `"abd` to produce `abd`, without the double quote. Here's the code I've tried:
Remove multiple whitespaces
Remove multiple whitespaces I'm getting `$row['message']` from a MySQL database and I need to remove all whitespace like `\n` `\t` and so on. should be formatted to: I tried: b
- Modified
- 27 May at 16:14
How to delete all instances of a character in a string in python?
How to delete all instances of a character in a string in python? How do I delete all the instances of a character in this string? Here is my code: However, if I run this, this is what happens: ``` >>...
- Modified
- 5 Mar at 02:23
C# hexadecimal value 0x12, is an invalid character
C# hexadecimal value 0x12, is an invalid character I am loading a lot of xml documents and some of them return errors like "hexadecimal value 0x12, is an invalid character" and there are different cha...
- Modified
- 10 Jan at 19:46
PHP preg replace only allow numbers
PHP preg replace only allow numbers How can I modify this existing preg_replace to only allow numbers?
- Modified
- 9 Jan at 16:54
How to remove spaces and newlines in a string
How to remove spaces and newlines in a string sorry if they are not very practical for C # Asp.Net, I hope to make me understand I have this situation I would make sure that the string does not contai...