Questions tagged [replace]
Replacing is the action of searching a string for a sub-string and replacing it with a different string.
30,699
questions
0
votes
1
answer
251
views
How do I change SOME values in my SQL query result?
I have a result with a couple hundred rows, and I only want to change 2 values in a specific column.
I have tried
CASE GRUPPIERUNGSATTRIBUT08
WHEN '1043333138' THEN '##########'
WHEN '...
1
vote
1
answer
611
views
Fastest way for substring replacement in pandas
I have a list of substrings that I want to replace with ' '. What is the fastest way to do so? Is this possible with cython? This is really slow when applying it to 1 million row so fastest execution ...
-1
votes
1
answer
73
views
Is there a better way to replace a string in python? [duplicate]
I have a question I need to resolve, for example:
s1 = "1$<2d>46<2e>5"
str_dict = {
"<2c>": ",",
"<2e>": ".",
&...
0
votes
1
answer
53
views
Why am I getting the wrong output while using str.replace()?
My code has an index value that points to a character in a string and I have to replace all the instances of that character with the previous value and the next value alternatively except the value of ...
1
vote
1
answer
263
views
I am unable to replace a special character with 0 and then in return replace that 0 with a median value of my column
I have been an automobile dataset for a private project. I have '?' in my price column which I am planning to replace with a median value of the automobile companies price for different models. I am ...
0
votes
1
answer
128
views
str_replace_all using multiple conditions
I have two data frames ("before", "after").
before1 <- c("A", "B", "C")
before2 <- c("1", "2", "3")
before3 <- ...
0
votes
1
answer
59
views
string replace function giving unexpected outputs
I was writing a code that would substitute some random 17 character strings into a single alphabet, and it's giving me weird tampered outputs. Basically, what I'm trying to do is this:
getting input ...
1
vote
0
answers
725
views
Replace & with & in XML string in azure apim
I have an xml string which I am setting as body and transforming that xml into required ones.
XML String:
XML_STRING= "<A><B>abc</B><C>abc&ade</C></A>"...
2
votes
2
answers
67
views
Racking my brain trying to replace a substring in a formula without replacing a slightly larger substring?
To put it simply, I have a cell with the formula
=IF(A4="Name", IFERROR(J4*(I4-AI4), 0), "")
I am trying to replace "I4" with say "BH4" without "AI4" ...
2
votes
1
answer
78
views
Regex to handle a varying number of variables
I'm trying to change a string that looks something like this:
s = 'g1 & g2 & (X~(~g1 & ~g2) & ~o1) & (XX~(~g1 & ~g2) & ~o1 & X~o1)'
to this:
'g1_0 & g2_0 & (~(~...
1
vote
2
answers
278
views
String Replace that contains hashtags-php
I have a string like this
$content="#Love #Lovestories #Lovewalapyar";
Want to make these hashtags clickable.
I have an array.
$tags=
(
[0] => stdClass Object
(
[...
0
votes
2
answers
73
views
Array : Replace part of array object with other array object
I have an array :
{
"count": 8,
"id": "accountId",
"name": " Account Id",
"values": [
{
"count"...
1
vote
1
answer
146
views
Qt QRegExp: replace spaces in a quoted string
There is a line example:
text a b c text "text text1 text2" text d e f
I need to replace all spaces that are inside quotes. This can be solved with simpler string operations, but I would ...
0
votes
1
answer
276
views
EXCEL - Replace function | Replace value from one column to replace with other column value
Input should be like,
schema name
schema value
ps_din_ghr_${hiveoff:suffix}
post
and output should be like below in new coulmn:
schema name
ps_din_ghr_post
i want to replace after $ part with ...
0
votes
1
answer
242
views
NumberFormatException #1 Kotlin Replace String value
Error code
java.lang.NumberFormatException: For input string: "44,379.3933"
at java.lang.Integer.parseInt(Integer.java:615)
at java.lang.Integer.parseInt(Integer.java:650)
...
2
votes
1
answer
96
views
Loop over multiple values stored in single column e.g [345 1234]
I have a CSV file in which one column has stored two values at one position such as [345 1234] but sometimes there is no value such as [] or only one [456].
I write a script that works well for empty ...
0
votes
2
answers
363
views
Count and remove duplicates from an array
In Powershell I have the following array
foreach ($Record in $Records)
{ write-host $Record
}
@{car=OPEL; count=3}
@{car=BMW; count=2}
@{car=OPEL; count=8}
@{car=AUDI; count=3}
@{car=FORD; count=5}
@{...
1
vote
1
answer
453
views
Most efficient way to str.replace regex=True or similar in pandas?
Dozens of strings need to be replaced across multiple columns of thousands of dfs:
for df in dfs:
for col in columns:
for key, value in replacement_strs.items():
df[col] = df[...
0
votes
2
answers
48
views
Removing substrings from a Data Frame
I used the following code
remove_words=['Conference Call - Final.rtf','Conference Call - F(2).rtf','Final(2).rtf']
pat= '|'.join(remove_words)
pat
df['title'] = df['conference_name'].str.replace(pat,''...
0
votes
1
answer
701
views
Laravel how to replace a words in string
I am trying to change words in string, I know laravel Str::replace() function but it converts if you write exact word. This is what i want to do :
$string = " this is @username and this is @...
0
votes
1
answer
661
views
In Python IDLE How to replace one character in regex search in replace dialog?
Let's say I have bunch of lines like this:
file.write('string')
and want to rewrite them fast into
text += 'string'
I can replace the file.write( part without using regex because I want to replace ...
2
votes
2
answers
693
views
Replace text but not if contain specific characters?
In JavaScript, I am using the below code to replace text that matches a certain string. The replacement wraps the string like this: "A(hello)". It works great but if there are two strings ...
0
votes
1
answer
67
views
How to remove the last comma in javascript
let str = "Testing, how to, remove, comma"
How can I remove that last comma (,) between "remove" and "comma" using JavaScript? Preference using replace with regex
0
votes
0
answers
49
views
How can we find and replace words while matching two text files?
I have two word databases in different formats for two different dictionaries. One of them includes a hyphenated version of each word (e.g. ad‧mi‧ra‧tion for admiration) while the other does not. My ...
0
votes
2
answers
36
views
How can I replace multiple object properties inside array
I'm writing a NODE.JS code that presents the user with some data about his account inside a game.
It sends a GET request to the game API, and the API returns an array with the amount of "points&...
0
votes
1
answer
45
views
Is there a possible way to use multidimensional arrays to replace words in a string using str_replace() and the array() function?
Note: I have seen this question here, but my array is completely different.
Hello everyone. I have been trying to make a censoring program for my website. What I ended up with was:
$wordsList = [
...
1
vote
2
answers
578
views
how to map and concat value two data frame python
one dataframe as
first = pd.DataFrame({'Code': [1,2,3,4],'Value': ['Apple','Ornage','Bannana', 'Graps']})
and another data frame is
second= pd.DataFrame({'Code': ['1','2','1','2,4','3'],'Product id': ...
1
vote
2
answers
70
views
I have column entries mixed with multiple "_" character, how can I replace the figure before the first "_" with a function while leaving the rest
I have column entries that have characters mixed with multiple '_ ' (e.g. 67_0000100-478_NA_d202xz97406_t17199m2156).
Using SQL (DB is Postgres), I want to replace only the figure before the first '_' ...
0
votes
2
answers
38
views
Script function replace is not changing the cell
I created this function to change specific cell value, from "5.000,00 C" to "5.000,00":
But when I run the function the cell does not change.
I don't know what I'm doing wrong.
...
0
votes
0
answers
56
views
MultiFInd Replace Based On Table MakroExcelVBA
I have the issue with this code below
When I have about more then 80 phrases to replace macro skips some random phrases.
When I isolate this phrase macro was fine.
Sub MultiFindNReplace()
Dim Rng ...
1
vote
0
answers
295
views
Time zones in datetime
I am experiencing differences in the way time zone definitions are applied in datetime.now(tzinfo=xxx) and in the replace method datetime.now().replace(tzinfo=xxx)
Example:
from datetime import ...
0
votes
1
answer
43
views
Find and substitute values from XML files
I'm trying to automate the replacement of translations from one XML file to another. The original translator set the translation in the wrong files, and I'm trying to restore them back with an ...
0
votes
1
answer
24
views
Inserting a tag around a specific character in a title
I need to replace 'No' with 'No' inside an h1 heading using vanilla javascript. So in a nutshell I would like to find the h1 tag by searching for it's class '.product__title', search the text inside ...
0
votes
0
answers
15
views
How to search and replace while ignoring placeholders? [duplicate]
I'd like to perform a search and replace, preferably in VSCode, but a command line program or something like a Python script will do.
Ideally, I would be able to perform the search and replace across ...
1
vote
1
answer
161
views
coldfusion bug in Replace function
Here is my program:
<cfset test = 'a~b~~c~d~~~e'>
<cfset test2 = Replace(test, '~~','~X~','all')>
<cfoutput>
test #test#
<br> test2 #test2#
<br>wanted: ...
0
votes
0
answers
85
views
How do I use str_replace with a search array and replace it with part of the search array that was found?
I am doing a str_replace with a search array and I want to replace it with a string that includes the value in the array that was found.
This is my search array
$search_array = array("**JOB ...
1
vote
3
answers
550
views
how can I replace NaN value with data from another dataframe in python?
from io import StringIO
import pandas as pd
x1 = """No.,col1,col2,col3,A
123,2,5,2,NaN
453,4,3,1,3
146,7,9,4,2
175,2,4,3,NaN
643,0,0,0,2
"""
x2 = """No.,...
0
votes
5
answers
1k
views
Convert one string password to all asterisks
I want to encrypt the password when it shows out in registration report, instead of showing the real password I would like to encrypt all the value to an asterisk (*) I tried to replace all character ...
0
votes
1
answer
615
views
Replace with "?" all elements in a slice / create a string with ?, for as many elements in a slice
I'm doing my first assignment in Golang, hence this may be silly question.
I have a situation where I need to create a query dynamically that takes an array (slice) of parameters, thus an equal number ...
0
votes
2
answers
136
views
Reg Exp replace to match hh:mm format in oracle
Write an oracle query using regexp replace to fix space and return hh:mm format.
with
test_data (srt_tm) as (
select '1:00' from dual union all
select '01:00' from dual union all
select ...
1
vote
2
answers
291
views
Pandas replace values (grouping by and iteration)
Good morning
I have a current problem when trying to replace some values. I have a dataframe that has a column "loc10p" that separates the records into 10 groups, and for each group I have ...
0
votes
1
answer
247
views
Replace string on XML file - Set-Content not working
I'm trying to do find/replace on an start menu XML file:
The XML file:
<LayoutModificationTemplate Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification"...
2
votes
3
answers
606
views
How to replace values in a matrix below the diagonal from bottom left to top right?
Given is a matrix (no assumptions are made about its dimensions) which contains zeros below the diagonal that runs from the bottom left to the upper right corner:
m <- matrix(data = c(2, 1, 8, 9, 1,...
0
votes
1
answer
108
views
Python(Pandas): Replacing specific NaN values conditional on information about other observations in the dataframe
If have a data frame where each observation has a UniqueID identifying the observation and a ObjectID identifying the object. There can be multiple observations for the same object, i.e. the ObjectID ...
0
votes
1
answer
63
views
How to add a string with breakrule to a PHP array to use in Javascript
I'm constructing an array in PHP to use it in my Javascript code. So I'm looping over all the posts (Wordpress) and push all the values to a string - which is the Javascript array:
<?php while ( $...
0
votes
2
answers
44
views
So I just created a text file and copied text from an already existing file using a with loop. How do I open newly created file in same prog?
I'm making a program that takes text from an input file, then you input a file where it copies the already existing file text. Then, I need to replace a few words there and print the count of how many ...
0
votes
1
answer
561
views
remove bracket, double quote, and possibly add space using string.replaceall in java
I saw multiple thread answering about how to replace/remove single quote ('), double quote ("), bracket ([,{), commas, etc. While I was able to successfully remove them, but I would like to ...
-1
votes
2
answers
121
views
Regex - replace quotes except attribute ones
I have a following text
<a href="#" class="name">here is "quoted"</a> and another in "quote" and alone quote - ".
and I need a regex where I ...
0
votes
1
answer
276
views
How to Replace a string taking an input from another file in Linux Shell script
i have an existing users ID and wanted to change those IDs to users name
for e.g.
UserID.txt
Group1 = 1234,1002,2004
group2 = 3214,0032,6632
1234 = Read
6632 = Write
Input_file.csv
search for ...