Questions tagged [replace]

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

0
votes
1answer
13 views

Replace escape sequence characters in a string in Python 3.x

I have used the following code to replace the escaped characters in a string. I have first done splitting by \n and the used re.sub(), but still I dont know what I am missing, the code is not working ...
1
vote
3answers
44 views

Replace occurence in a String in Kotlin

I have two list of Strings. Now I want to replace every occurence of a word in the first list at index i with a word in the second list at index i of a sentence. So if I have list a=("am","I","my")...
0
votes
1answer
28 views

javascript regex doesn't match emails when url matching is passed

Am trying to match email,phone,email,hashtags and mention tag in a message and insert them inside a hyper link. But am having problem with my regex as it doesn't match emails as mail instead it match ...
3
votes
2answers
78 views

How to replace string in python from a list of possible strings

I have a column of data that looks like this: df = pd.DataFrame({'Ex1':['apple','apple1','Peear','peAr','b$nana','Bananas'], 'Ex2': ['Applet','banan','apples','PAIR','banana','apple'], 'Ex3':['Pears',...
0
votes
2answers
27 views

Replacing value in a column that contains specific label and to replace them

i have a pandas dataframe with a column named period with 3 different labelling value which means winter 2019, winter 2020 and winter 2021 as shown below my question is how do i replace this format ...
0
votes
0answers
18 views

How can i replace a table string with another table string?

I have a little problem with my mysql that I can't solve myself. My problem is very simple: I want to update locale_name in item_proto table, when item_proto_copy.name = item_proto.vnum!
1
vote
1answer
25 views

Replacing values in high-frequency data

I've got high frequency data about durations. I've found out that I've got some faulty entries that I cannot discard that have 1800*random number added to them. Now I was stupid enough to try: for(i ...
-3
votes
2answers
62 views

C# replace string if string has other characters from both ends

I want to replace a string if it is a part of another string from both ends. Say for example a string +35343+3566. I want to replace +35 with 0 only if it is surrounded with characters from both ...
0
votes
1answer
29 views

Is there a function for replace a value through the list? [duplicate]

Currently, I'm working on a list like this txt=['S&P 500 Index', '2,905.03', '+4.58', '+0.16%'] Since I need to convert all the numerical value into float ...
8
votes
1answer
85 views

Substitute: replacement evaluation

Is the first and the second substitution equivalent if the replacement is passed in a variable? #!/usr/bin/env perl6 use v6; my $foo ='switch'; my $t1 = my $t2 = my $t3 = my $t4 ='this has a $foo ...
0
votes
1answer
28 views

Replace images with font awesome

I'm trying to change the code for displaying images for reviews. The previous code has 5 images of stars. The first image has one star, the next two and so on. The width of each image is the same so ...
-1
votes
1answer
13 views

shell: Replace all occurances of particular text contained between arbitrary “start” and “finish”

I want a one liner run from nix shell to replace all occurances of particular text contained between arbitrary "start" and "finish", e.g. in nfw987__qrh fwef_start_hf9 832j fsjdlkfa;jd(&6^)lf ...
1
vote
0answers
24 views

Replace $ sign in all document [duplicate]

How to replace all '$' characters in my page anywhere when page is ON load. $ can come multiple times in, So we need to replace all '$' with the '+'. Here's what I have: MY HTML: <div>$a sa d $...
0
votes
1answer
40 views

Is There A Way To Use Regex Containing Variables To Replace Characters In A String

I already have the code s.replaceFirst("\\.", "");. This replaces the dot in the given string s. But my problem is, that it shall be able to change, what is going to be replaced. Like for example, the ...
2
votes
1answer
30 views

R Replace Data with NA

Hy there I have a table with some observations in different depths, where i d like to replace the Value of few observations with NA, if the Value of Observation 7 is negative, but otherwise it should ...
3
votes
4answers
63 views

How to remove user defined characters from a user defined string with python?

How to remove user defined letters from a user defined sentence in Python? Hi, if anyone is willing to take the time to try and help me out with some python code. I am currently doing a software ...
1
vote
2answers
22 views

How to conditionally replace values with NA across multiple columns

I would like to replace outliers in each column of a dataframe with NA. If for example we define outliers as being any value greater than 3 standard deviations from the mean I can achieve this per ...
1
vote
4answers
41 views

If found a pattern, how to paste the last line before that contain another pattern in bash?

After put a list of all folders and subfolders in a list.txt with the command ls -R, I have this kind of data: Invertebrates/Phylum_echinoderma/Class_Echinoidea/Fam_Diadematidae/Sp_01: DSCF0214.JPG ...
1
vote
1answer
43 views

How to get a valid iterator after string replacement

I want to do some string replacement in C++ under Windows using iterators. This is the code : #include <stdio.h> #include <iostream> #include <string> #include <iterator> ...
-3
votes
1answer
22 views

How to perform regex tag conversions to all occurrences in a string in PHP?

I want to convert my html strings which contain <p style=“text-align:center; others-style:value;”>Content</p> to <center>Content</center>, and <p style=“text-align:right; ...
-2
votes
0answers
7 views

How to perform random sampling with replacement in SQL (bootstrapping)

I would like to perform random sampling with replacement in SQL (bootstrapping). For my example problem, I'll borrow the example from https://www.thoughtco.com/what-is-bootstrapping-in-statistics-...
-1
votes
2answers
120 views

Replace Strings with specific list of words

Replace a given string at given index with list of words. The problem statement goes below, can someone give me some intuition or idea how to proceed on this? //A replacement class similar to Linked ...
0
votes
0answers
30 views

str.replace issue in pandas

This works x['Series'].str.replace("IONIQ HYBRID", 'IONIQ_HYBRID', regex = True) And this does not x[x['Series'].str.replace("IONIQ HYBRID", 'IONIQ_HYBRID', regex = True)] What am I missing?
0
votes
3answers
59 views

How to change numeric variable into categorical [duplicate]

im trying to change the "Wine" variable to a categorical variable wine_df wine_df$Wine [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
2
votes
3answers
37 views

Regular expression - replace specific string based on different string condition

I am dealing with a replacement of many lines of code. What I need to do is to replace specific string based on various conditions. Here is the string: private IWebElement UserList_Link { get; set; } ...
0
votes
0answers
29 views

ApachePOI extract digits from RichTextString

I am reading cell values from one Excel sheet and placing them in another with Apache POI. For one particular column I would like to only copy over the numbers of that cell. Naturally I tried this: ...
3
votes
1answer
42 views

Regex to replace first lowercase character in a line into uppercase

I have a very large file containing thousands of sentences. In all of them, the first word of each sentence begins with lowercase, but I need them to begin with uppercase. I looked through the site ...
0
votes
0answers
26 views

Replace single quotes from list items of type string [duplicate]

I have read several similar questions but I couldn't solve my problem. I have a list with string items for example: mylist = ['This', 'is', 'an', 'example', 'sentence'] and i want to discard the ...
0
votes
0answers
9 views

Replacing function in llvm with different types

My module pass is trying to replace function call foo with function call bar. The functions may have different parameters and return types. I have tried the following snippet but getting "Wrong types ...
3
votes
3answers
54 views

How to replace consecutive and identical characters in Perl?

I have a string like XXXXYYYYZZZYYZZZYYYY which needs to be converted to XXXXAAAYZZZAYZZZAAAY $s =~ s/Y{2}+/AY/g; this has 2 problems, {2}+ will get YYYY to AYAY; and AY is not the same length as ...
1
vote
1answer
20 views

How to remove/delete characters from end of string that match another end of string

I have thousands of strings (not in English) that are in this format: ['MyWordMyWordSuffix', 'SameVocabularyItemMyWordSuffix'] I want to return the following: ['MyWordMyWordSuffix', '...
2
votes
1answer
32 views

Regex and replacement with numbers and texts

In a epub code, I have this text: <span>Capitulo 1 - Apple is red</span> <span>Capitulo 2 - Milk is white</span> <span>Capitulo 3 - Weeds are green</span> I need ...
0
votes
2answers
39 views

Replace apostrophe in JSON with apostrophe suitable for curl via sed

I need to prepare JSON which contains apostrophe to be sent via CURL. Example of JSON: {"myField":"Apos'test"} Example of JSON I need as an output: {"myField":"Apos'\''test"} What I have tried: ...
0
votes
0answers
20 views

How to single-escape a Pipe in a string: Unexpected str.replace behaviour [duplicate]

Python's str.replace seems to be doing "clever" character escaping and the docs don't show any way to 'override' this behaviour. Expected: x ="val|with|pipe" x.replace("|","\|") >>> "val\...
0
votes
2answers
31 views

How can I append a value replacing multiple elements in a list?

I'm trying to make a search system that finds the search keyword containing mutiple ANDs, ORs, and parentheses. What I'm trying to do now is replacing the parenthesis with boolean values. So if I ...
2
votes
1answer
43 views

Replace part of a function/variable name with C macros

I am writing some code that I will want to use multiple times with slightly different function and variable names. I want to replace part of the function and variable names with a macro. gcc filename....
2
votes
1answer
68 views

RegEx for making a tag conversion in PHP

For some reasons, I want to convert strings which contain <p style=“text-align:center; others-style:value;”>Content</p> to <center>Content</center> in PHP. The text-align ...
0
votes
1answer
25 views

I'm trying to drop cells in a Pandas Dataframe that contain countless spaces

When importing from a certain log file, I get a pandas dataframe containing cells with strings (including spaces) separated by cells that contain many and only spaces that seem to change in count ...
0
votes
0answers
34 views

String find and replace going out of bounds

I am trying to find and replace codons in a sequence with ribosomes. A large string is checked with an index from the search array, and if a match is found, that 3 letter codon is replaced with the ...
-1
votes
1answer
23 views

In R is there a way to replace a specific text in several lines of code?

I would like to run the same code but change the name of the data frame each time so I can run the same analysis for several different datasets I have. Is there a more efficient way to alter my code ...
0
votes
1answer
42 views

How to replace a OR b using powershell command in a batch file?

I want to replace a string in a file with another string. However, the string to find could be one of two values. Example: 'cool' changed to 'fun' 'uncool' changed to 'fun' It works if I only try ...
1
vote
4answers
44 views

How to sequentially replace substrings in a vector with strings in another vector in R using map function?

I have a vector of three character strings which all contain the substring "X": v<- c("kpX_43", "kpX_10", "kpX_11") "X" is a place holder that is either filled by "1", "2", "3" or "a1". Now, what ...
0
votes
1answer
40 views

Python 2.7 path replace string

I need to replace some string by others. I'm using function pathlib to do that it's working fine but I have a problem when there is two same string in my file and I need to change just one My file (...
0
votes
0answers
16 views

How can I search and replace many phrases in many files in quick time? [closed]

I have 3 types of files. Original .csv files, files with the same name, but .txt, that contains phrases to edit in original files, and .txt files that contains tanslated phrases to put in orignal .csv....
0
votes
1answer
50 views

How to delete lines with specific subjects from an RDF file?

I have a file containing triple RDF (subject-predicate-object) in the turtle syntax (.ttl), and I have another file in which I only have some subjects. For example: <http://dbpedia.org/resource/...
-1
votes
4answers
64 views

How to replace specific value in list?

I´ve the following list: x = [['0_1 1_0']] I want to replace 0_1 with 0. This is what ive already tried: x[0].replace("0_1", "0") But then I get the following erorr: AttributeError: 'list' ...
1
vote
1answer
23 views

How to perform regex substitutions on chapter including theirs numbers with Calibre?

I have the following sequence in a epub file:CHAPTER 1CHAPTER 2CHAPTER 3 I want to add a head tag for each of them, so i use the replacement module of Calibre:Find: CHAPTER *Replace with:<h1>...
-1
votes
0answers
15 views

Formula to find img tag and add .jpg before closing the src double quote in excel

I'm trying add jpg extension to the text inside a cell inside img src tag in excel, here is the sample text The spotlight has shone on two students from Northwestern University Film Festival. <br /...
0
votes
0answers
50 views

Excel VBA: Copy & replacing sheets CodeName fails, -Script out of range

In my excel woorkbook I have 4 Sheets with tab names: Sheet1 Sheet2 Sheet3 RandomName The CodeNames for Sheet1 is Test1A Sheet2 is Test2A Sheet3 is Test3A RandomName is Sheet4 I want the following ...
0
votes
1answer
21 views

modifying character variable contents based on lookup table in SAS

HAVE is a wide dataset with names stored in the variables name1-name250. Here are the first two obs and several vars: episode name1 name2 name3 name4 name5 ...

http://mssss.yulina-kosm.ru