All Questions
Tagged with str-replace or replace
31,000 questions
0
votes
1
answer
27
views
How to use Javascript async/await in semi-asynchronous situations? (e.g. in String.replace) [duplicate]
For example I'm doing a RegExp replacement on a body of text:
text = text.replace(re, function (match, comment, op1, op2, op3, op4, op5, op6, op7) {
if (op1 !== undefined) {
log("...
-1
votes
2
answers
33
views
Replacing an image with an image link
there are several images on a page like this
<img src="https://images4.imagebam.com/qwert.jpg" alt="" />
<img src="https://images4.imagebam.com/werty.jpg" alt=&...
0
votes
0
answers
12
views
How to find and remove code block accross multiple html files in subdirectories
Lets say I’m working on a project where I need to remove a specific block of SEO-related code from hundreds of index.html files located in various subdirectories within a root directory. Here's the ...
-1
votes
1
answer
48
views
Trying to use the replace method in python to replace single/double quotes [closed]
I am working on an assignment for a beginners level python course I am taking in highschool. I am looking over some data from a text file, which I have turned into a list of lists. I am trying to get ...
0
votes
0
answers
15
views
Unhandled error during execution of component update when click vue3 simpletypehead
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'length') this error was showing when i click the vue3 simple typeheaad
how to fix this error
when i click the input field in ...
0
votes
1
answer
49
views
How to Highlight Search Terms in HTML Ignoring Case and Accents Using JavaScript?
I am working on a scenario where I want to highlight words or parts of words that people search for. I have a function called addMarks that wraps the searched word in the <mark> tag. Of course, ...
0
votes
1
answer
29
views
How to get ID of last inserted or updated row when using $wpdb->query
I am inserting data in a Wordpress plugin table using a custom query using the $wpdb->query() method. I use a custom query because I need to run ON DUPLICATE KEY UPDATE. Is there a way to retrieve ...
0
votes
1
answer
52
views
VBA Replace “Start” attribute deletes text
This is a weird one. I am trying to replace the second occurrence of a value using the Replace function. This is what I have.
Sub_string = Replace(sub_string, "<ul>", "", ...
0
votes
3
answers
67
views
Three matched ID# columns in a single dataframe one of them has NAs that I need to fill in using the existing data in R
I combined two dataframes using two different shared ID columns ("name" and "idA"). One of the datasets had a third ID column that was retained ("idB"). Now I have one ...
3
votes
1
answer
314
views
Pandas replace and downcasting deprecation since version 2.2.0
Replacing strings by numerical values used to be easy, but since pandas 2.2. the simple approach below throws a warning. What is the "correct" way to do this now?
>>> s = pd.Series([...
0
votes
0
answers
35
views
Delete repeated adjacent characters from the string in snowflake?
I have a string: 'ABC/DEF-GHI/GHI/IJK-LMN/GHI'
I want to delete the repeated occurrence of GHI followed by DEF-GHI, but not delete the last GHI because it is not adjacent to another GHI.
Expected ...
0
votes
0
answers
33
views
From matplotlib to latex. Good idea to change the mathematical expressions?
I have a question regarding matplotlib and latex. What I am doing is to create a plot in matplotlib and export it as pgf. This is an example:
import matplotlib.pyplot as plt
import numpy as np
# ...
-1
votes
1
answer
59
views
How to parse an ini-like string into an array
I'm working on a song database application with an existing database. In the editor the songs are laid out like this in the contents column:
[chorus]
And all will surely agree,
There's nothing like ...
0
votes
1
answer
29
views
String cleaning removing consecutive value and put comma in the end
I have this string from an email I'm scraping:
TICKET\xa0\xa0 STATE\xa0\xa0\xa0\xa0 ACCOUNT IDENTIFIER\xa0\xa0\xa0 FILE DIRECTORY\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\...
0
votes
1
answer
76
views
Find/replace with variables
I'm trying to write a perl script to remove strings from a mariadb database that contains articles from a Joomla website. Our AI tool is inserting extra junk in the database that needs to be removed. ...
-3
votes
3
answers
76
views
regex in vim: how can I replace `+` expanded characters
I am trying to replace all leading occurrences of = with #.
=
lorem
==
ipsum
====
foo=bar
Ususally I would do something like this.
:%s/^====/####/g
:%s/^===/###/g
:%s/^==/##/g
:%s/^=/#/g
Not nice, ...
-2
votes
1
answer
44
views
Linux: sed to replace string1 but only with grep string2 [duplicate]
I should replace a certain string in a file but only in rows where appear another string, example:
This is myfile
Hello world
the world is mine
I would replace "world" only in the rows with ...
-1
votes
1
answer
66
views
Replace variables with values from a database in a string containing HTML
I have a string received from an editor, which includes HTML tags, like this:
const htmlString = "<div>Account <span contenteditable="false">{{account}}</span></div&...
3
votes
5
answers
82
views
how to replace zero with incremental value in in R data frame?
I have a dataset where I want to replace each zero with incrementing values: the first zero becomes 0.001, the second 0.002, the third 0.003, and so on. Each time a zero appears, it should increase by ...
-2
votes
5
answers
83
views
Remove character for specific column
I need to remove thousand comma separator (,) in Total Chargeable column. Currently i'm using
line = line.replace(',', ''); but then it will remove all commas.
Any suggestions how we can remove ...
0
votes
2
answers
45
views
Create a pattern to capture with a text which does not have letters or numbers behind or infront of them
I am using REGEXP_REPLACE to replace a character set which does not have a number or character infront or behind them.
Basically my reqirement is to remove the word PT, but only when it is not used in ...
5
votes
3
answers
119
views
sed regex, match first instance between varied delimeters
I have a set of hashes that I want to anonymize. Using GNU sed (v4.9), how can I replace only parts of the hash with something else? Specifically for my case, I want to preserve the $ symbol if it ...
2
votes
2
answers
57
views
Need to replace multiple values in a text string, within the given column in one query/step
Problem statement:
I would like to replace multiple values within a text string only if found, all in one step.
Example: In my column of 8000 rows,
I want to replace @ symbol with *40 in text string ...
0
votes
0
answers
43
views
how to fix VS Code search working inappropriate
In VScode am trying to search in all files and replace the copyright year from 2023 to 2025 but the search is not finding correct characters. And so the replace is not working as intended. instead ...
0
votes
0
answers
24
views
Find & replace multiline text block without eol
col1 col2 col3
----------------- -------------- ----
hello_world 345 1234
The goal is to remove multiline intext pattern:
-
to get this:
col1 col2 ...
0
votes
2
answers
61
views
Replace characters in array
Sub REPCHAR()
Dim Massive(2), DATA As Variant, RES As Variant, LC As String, I As Long, N As Long
Dim Dic: Set Dic = CreateObject("Scripting.Dictionary")
With Sheets("1&...
0
votes
0
answers
25
views
VSCode Replace Regex with Regex [duplicate]
I created a script that create markdown files. The problem is that half of my <td> don't have an end statement and i have about 5000 to replace.
So I tried to use the Find and replace function ...
2
votes
2
answers
66
views
Is there a R function that detects a specific string and replaces it by the value of another observation based on a number within the string?
So, I am using constituency data of the German Election 1994 and some observations contain strings that indicate that the value is given in a different row (based on the Scheme "siehe Wkr xxx&...
0
votes
0
answers
53
views
Excel cannot find string within formula
I am pulling data from an unstructured data souce with variable number of items per record but I need to process the data in fixed arrays. Anyway, I have parsed each record into a tab "1" &...
3
votes
3
answers
110
views
Add a space around equals-sign if not already whitespace
I am trying to work out a Perl regex for adding in a space around equals sign ("=") - but only if there isn't a space there already:
var myVariable="thisValue" -> var myVariable ...
0
votes
1
answer
59
views
Pandas replacing values in array from the gridded (Lat, Lon, Value)
I am stuck to replace (correction) the values of an array from the given Latitude, Longitude and Rain value for hundreds dataset. Here some part of dataset that I am dealing with:
Lat Lon Rain
6....
1
vote
2
answers
99
views
Powershell script for find/replace multiple items in a batch file
I am trying to write a powershell script that will take IP addresses (subnets) in a batch file and replace them with an updated value. I am using the following code but the replacements are not all ...
0
votes
2
answers
58
views
Excel VBA: Use MsgBox if Replace finds nothing to replace
I'm using a simple code to find values in a range and if that value is found, all instances of it are cleared with a "".
The code:
Sub Clear()
Range("A1:R34").Replace What:=...
1
vote
2
answers
77
views
why does string -replace operator to duplicate backslashes (as neeeded for wmic input) result in 4 backslashes
One might need to replace each backslash in a string, say a file path, with double-backslash. Eg, wmic requires this (eg: https://stackoverflow.com/a/50878476/4582204).
So one might try this code
'foo\...
-2
votes
2
answers
110
views
'list' object has no attribute 'replace'
I'm working on some code to encrypt a word into numbers from the polybius square, however I need the output to be the two numbers right next to each other e.g. 41 instead of a coordinate format (4, 1)....
0
votes
0
answers
35
views
Data lineage - Remove the all comments from [VIEW_DEFINITION] in Azure SQL DW [duplicate]
I need to list the columns and tables that are used in the creation of the view [dimension].[v_dim_customer] .
To do this, I query the value of the column [VIEW_DEFINITION] which contains the SQL ...
1
vote
2
answers
87
views
remove the first character of each .txt file with Powershell
I have 50 files in a folder that has to be loaded to SQL.
In most of the file(but not in all) the very first character is a hashtag that i would like to delete because it creates difficulty in the ...
-1
votes
1
answer
43
views
How to pair up the same strings in two table where in one of them they have a '?' replacing some of the characters?
I have names of people in a table as primary keys and I have them in another as foreign keys except in this second table they have been occasionally recorded faultily, with a '?' symbol replacing a ...
1
vote
3
answers
76
views
How to add single quotes to one of the columns in PowerShell?
I have the following lines in a file:
pc_cc_text$fx_review1 CONSTANT VARCHAR2(100) := 'For Company Review'; -- AD_PRT_AUTH_(MSP)
pc_cc_text$fx_review2 CONSTANT VARCHAR2(100) := 'For Dept Review'; -- ...
1
vote
2
answers
56
views
Replace values in data frame if value is greater or smaller depending on values in first column
I have problem manipulating my big data-frame in R. This seems to be a basic thing in R, but I can't find a solution.
Dummy example for df:
threshold V1 V2 V3 V4
#1 10 1 100 ...
1
vote
1
answer
83
views
How to convert a string variable into a numeric variable?
I have data from a survey with variables containing strings that I would like to convert to a numeric value for analysis. They also contain some blanks. I use Stata 15.1 to perform the analysis. Here ...
0
votes
2
answers
40
views
dynamic insertion of missing using tidyverse
I am working a couple of functions that will save me a lot of time in my data wrangling workflow. I am trying to provide R with a list of columns. I want to loop over those columns looking for ...
1
vote
2
answers
70
views
Vim Search, Replace And Match Length Of Numbers By Appending Zeroes
I have a pattern in XML that I want to search and then replace by appending zeroes such that all the replaced numbers will have same length.
Pattern to search is as shown below:
<title>99
<...
0
votes
2
answers
106
views
substr_replace() calls on a result string inside a nested loop causes replacements on replaced text
I'm working on a project that takes text files from a folder and searches the text of each file for specific keywords that correspond to image files that I'm trying to insert in the text as an html ...
0
votes
1
answer
86
views
How to get string/regex replace preview (like in VS Code) in Emacs, with a single hotkey?
What I want
In VS Code, I can press Ctrl + Shift + h and get a convenient preview (see screenshot) of replace candidates. It allows to navigate all matches, and do a replacement with a hotkey.
What ...
0
votes
0
answers
32
views
Power shell need help removing spaces from an .IDX file
I have files coming in automatically and they come in with a "; " when I need ";" I can't switch them at the sender's side so I am creating a Power shell to adjust them I then am ...
-2
votes
1
answer
67
views
How to change only certain elements, keeping intact other elements with the search module in VS Code?
I want to know how is it possible to change some HTML tag such as :
<tag1>[my text]</tag1>
to another type of tag such as :
<tag2>[my text]</tag2>
but keeping the inner text ...
2
votes
2
answers
63
views
Script block in replace string using powershell
I am searching for following regex pattern in a file
"[a-zA-Z0-9]+[^"]+[a-zA-Z0-9]+"
This pattern contains all text including spaces. I am trying to Replace spaces(\s) to underscore(_) ...
0
votes
1
answer
60
views
Replacing multiple characters in single column in result set
So I am trying to create a fixed length flat file from the result set of this query, however there are three name fields where I have to strip out hyphens, apostrophes, spaces, periods, suffixes (Jr) ...
-3
votes
4
answers
120
views
Replace only some words using a regular expression [closed]
I have a text with many "PROB TEMPO" and "TEMPO" words, and I want to insert a line break just before the word "PROB" or before the word "TEMPO" when PROB doesn´...