Substituting string excerpts via sed, awk and other utilities.
Questions tagged [string-substitution]
220 questions
1
vote
3 answers
grep() and sub() and regular expression
I'd like to change the variable names in my data.frame from e.g. "pmm_StartTimev4_E2_C19_1" to "pmm_StartTimev4_E2_C19". So if the name ends with an underscore followed by any number it gets removed.
But I'd like for this to happen only if the…

LLL
- 723
- 1
- 9
- 27
1
vote
2 answers
APEX substitution string disappearing
I'm running APEX 5.1 on ORACLE 12.1.
I have ca. 80 APEX similar applications running on the same database - each application is using the same substitution string :CLIENT_ID with its own value (storing a code name of the application).
:CLIENT_ID…

PiC
- 137
- 10
1
vote
1 answer
APEX - passing substitution string in PL/SQL
I'm having some difficulty passing session substitution strings in APEX 5.
I have a process in my APEX application which will change the password of a user on a remote database. The username is set from the local LDAP authentication so is held in…

Huskie69
- 795
- 3
- 11
- 31
1
vote
1 answer
Which regular expression is more appropriate?
I am trying to make models output prettier with pre-defined labels for my variables. I have a vector of variable names (a), a vector of labels (b) and model terms (c).
I have to match the vectors (a) and (c) and replace (a) by (b). I found this…

Márcio Augusto Diniz
- 286
- 1
- 10
1
vote
3 answers
gsubfn | Replace text using variables in Substitution
I am trying to remove a block of text that wraps around what I want to keep. So I wanted to assign variables since the text can be long. This is an example of what I am trying to do. [Doesn't remove the text]
Text<-'This is an example text [] test'…

Koolakuf_DR
- 467
- 4
- 16
1
vote
2 answers
"%" character cause Error in strings substitution with locals()
I try to substitue strings with variables using locals() in python but I can find a way to use the % character inside the string without error. Here is a concrete example :
color = colors_generator() #the function return a color
html =…

Thammas
- 973
- 2
- 9
- 14
1
vote
1 answer
String substitution when strings are externalized to a separate file
I have extracted all strings from my code and put them into a file called constants.ts ..
export class Constants {
public static API_URL = '/api/';
public static CREATE_CHILD_API_URL = Constants.API_URL + '%s' + '/create-child';
}
I'm able to…

bobbyrne01
- 6,295
- 19
- 80
- 150
1
vote
4 answers
Batch Manipulating String by Input Variable Using "=&rem."
Using Server 2016 here with simple batch-file programming (for now).
I have what I think is an easy problem, just that I am not seeing a workable solution in front of me right now. I'm going to limit my request right down to a testing scenario to…

GHTurbines
- 13
- 2
1
vote
1 answer
Ruby string substitution with multiple options
I want to do string substitution. With gsub or tr I can give a single input character and map it to a single output value but I want to create multiple output strings based on multiple mappings:
swap = {
'a' => ['$', '%', '^'],
'b' => ['3'],
…

Robin
- 43
- 1
- 4
1
vote
1 answer
sed: Is there an option to substitute the Nth AND Mth occurrence of a match per line?
I believe I am asking about pattern flags.
I am familiar with the global pattern flag 'g'
sed 's/pattern/sub/g'
And I know I can substitute the Nth occurrence of a match by using a number.
sed 's/pattern/sub/2'
But suppose I wanted to substitute the…

Kreganthus
- 124
- 5
1
vote
1 answer
How to use Bash parameter substitution in a Makefile?
I've the following Makefile where I'd like to use Bash parameter substitution syntax as below:
SHELL:=/bin/bash
Foo=Bar
all:
@echo ${Foo}
@echo ${Foo/Bar/OK}
However it doesn't work as expected, as the output of the second echo command is…

kenorb
- 155,785
- 88
- 678
- 743
1
vote
4 answers
Bash one-liner for isolating directory name
In Bash, v.4.3.11(1) I have this sample code:
#!/bin/bash
dir=("/home/user/Documents/" "/home/user/Music/" "/home/user/Videos/" \
"/home/user/Photos/")
baseDir="/home/user/"
for i in "${!dir[@]}"
do
niceName=${dir[$i]#"$baseDir"} # removes…

knedas
- 178
- 2
- 13
1
vote
1 answer
Bash bad substitution
I'm working on a tiny script for school that has for goal to get a bmp file's size (file as parameter) using a single command line (no ; or &&)
So I did this :
#!/bin/bash
echo "size : ${$(xxd -p -seek 02 -l 4 $1):6:2}${$(xxd -p -seek 02 -l 4…

Voltra Neo
- 85
- 1
- 7
1
vote
4 answers
Substitution of characters limited to part of each input line
Have a file eg. Inventory.conf with lines like:
Int/domain—home.dir=/etc/int
I need to replace / and — before the = but not after.
Result should be:
Int_domain_home_dir=/etc/int
I have tried several sed commands but none seem to fit my need.

HoneyBee
- 23
- 4
1
vote
4 answers
How to use a JavaScript variable as a XHTML attributes value?
I have tried:
But using FireFox, the name is set to the literal string: "&{myVar};" instead of the value of…

markmnl
- 11,116
- 8
- 73
- 109