Substituting string excerpts via sed, awk and other utilities.
Questions tagged [string-substitution]
220 questions
0
votes
1 answer
Win CMD: How to escape "=" in string substitution
set "a=6=5"
echo %a%
6=5
echo "%a:6=5=6-5%"
"5=6-5=5"
should give me (the expected answer) 6-5 instead.
I've escaped = after expression to be replaced, but the = in the expression is treated by CMD as the delimiter of the substituent.
echo…

Zimba
- 2,854
- 18
- 26
0
votes
1 answer
Batch file change a drive letter string in a log file
trying to replace drive designation inside Idrive log files using a batch. Amateur programmer trying to understand batch files for years but still don't get advanced techniques. I suspect the '\' backslash needs to be escaped but nothing I try…

wschloss
- 15
- 1
- 5
0
votes
2 answers
Substituting values into web.config at runtime
We have an application that runs in three environments: development, QA, and production. The application accesses an SQL server and several web services. The web.config file has the connection string for the SQL server and the IP addresses of the…

dna86
- 407
- 2
- 7
- 18
0
votes
1 answer
String Substitution Using Variables in a FOR loop Batch Syntax
I am trying to use string substitution to truncate a list of full file paths down to relative paths in an existing text file. In addition there is some basic automated renaming. The renaming works as intended but the string substitution I cannot get…

Magstriker
- 3
- 4
0
votes
2 answers
bash native string manipulation displays jumbled output
I tried to use the bash string native manipulation for substituting string with my shell variables.
var1='123'
var2='2018-01-01'
var3='2018-01-02'
var4='myfunction('var1','var2','var3')'
var5=${var4/var1/$var1}
echo…

Jenny
- 355
- 1
- 2
- 10
0
votes
1 answer
Replacing info in HTML page using PHP before rendering
EDIT: After typing this out I think this approach is a non starter. All I am trying to do is to find an easier way to type = and ?> in longish HTML pages. Any ideas greatly appreciated.
LATER: Yep this is a non-starter so I am tweaking my IDE…

BeNice
- 2,165
- 2
- 23
- 38
0
votes
1 answer
Replace exact insensitive match of a string of interest while ignoring other strings having part of it
I am having difficulties replacing exact insensitive match of a string without affecting bigger strings having part of the string of interest.
What I mean is: if I have a string "INFO", I want to replace it with "INFORMATION" and if for instance I…

c1377554
- 173
- 1
- 10
0
votes
1 answer
How to read multiple lines in a template and substitute values?
I have a piece of standard text having multiple lines and some format like below:
owner: oracle
date_conditions: 1
timezone: US/Eastern
std_out_file: "/app/local/job.log"
machine: rachost
I want to use this above text with machine and…

vivek
- 111
- 7
0
votes
0 answers
How to replace the string with special characters in R in a loop?
I am trying to replace the strings with special characters using gsub. But I am running into error invalid regular expression '\bc++\b', reason 'Invalid use of repetition operators'.
df = data.frame("word"=c('c++', '.XLS','Java-prog'))
for i in…

Ana
- 325
- 2
- 11
0
votes
1 answer
Substitute multiple object values from a key value table in JavaScript / jQuery
I'm trying to figure out how to replace multiple object values using a key-value table.
I've been trying to learn from functions that do this on regular strings, and make it work for objects (specifically object values). I thought maybe there could…

Matthew
- 59
- 6
0
votes
0 answers
How to make excel run a fonction made with substitute and concatenate and calculate the number value
I want to make a graph in excel. So in one cell, i type the formula. (Let's say Sin(x). Then Somewhere else, i made a table of x values and y values. The x values goes from -5 to 5 with a step size of 0,01. I used substitute in the y column to…
0
votes
2 answers
Apply string substitutions line by line
I need to apply a series of substitutions on a text file, using a filter file with the same number of lines: line n of the filter should apply to line n of the original file.
E.g. original file:
foo
bar
foobar
Filter…

Skippy le Grand Gourou
- 6,976
- 4
- 60
- 76
0
votes
2 answers
using sed "r" to search for text and append contents of file
I'm reasonably well versed in using sed's inline function, along with it's ability to substitute as well as using different characters as the delimiter for it's functions, but I've now found myself using the "r" function to add the contents of an…

bnoeafk
- 489
- 4
- 16
0
votes
1 answer
How do I select and replace the main keyword in a pandas column of string?
Here's my data
Id Keyword
1 ayam e-commerce
2 biaya fuel personal wallet
3 pulsa sms virtualaccount
4 biaya koperasi personal
5 familymart personal
6 e-commerce pln
7 biaya onus
8 koperasi personal
9 biaya familymart personal
10 …

Nabih Bawazir
- 6,381
- 7
- 37
- 70
0
votes
2 answers
Using gsub to replace last occurence of string in R
I have the following character vector than I need to modify with gsub.
strings <- c("x", "pm2.5.median", "rmin.10000m", "rmin.2500m", "rmax.5000m")
Desired output of filtered strings:
"x", "pm2.5.median", "rmin", "rmin", "rmax"
My current attempt…

philiporlando
- 941
- 4
- 19
- 31