Questions tagged [substitution]

The action of replacing something with another thing.

The action of replacing something with another thing.

1879 questions
30
votes
2 answers

Substitutions inside Sphinx code blocks aren't replaced

In this reST example meant to be rendered by Sphinx, |yaco_url| doesn't get replaced because it's in a code-block: .. |yaco_url| replace:: http://yaco.es/ You can use wget to download it: .. code-block:: console $ wget…
Danny Navarro
  • 2,733
  • 1
  • 18
  • 22
30
votes
3 answers

How to get values from dictionary in jinja when key is a variable?

I'm trying to retrieve entries from a python dictionary in jinja2, but the problem is I don't know what key I want to access ahead of time - the key is stored in a variable called s.course. So my problem is I need to double-substitute this variable.…
tytk
  • 2,082
  • 3
  • 27
  • 39
29
votes
2 answers

How to Put Newline Characters in Substitutions of Regular Expressions of GVim

I use GVim on Windows 7. I want to learn how to put newline characters by using regex substitutions. To do this I try to use \r and \n metacharacters but the substituted text doesn't show normal newlines. For example, at the beginning I have: line…
Mert Nuhoglu
  • 9,695
  • 16
  • 79
  • 117
29
votes
4 answers

Excel escaping quotes or apostrophes in cell values

I get a lot of database information from clients in excel spreadsheets. I frequently need to insert/update this data back into the database. I often use excel to generate the insert and update statements via concatenating a bunch of cells together.…
Mir
  • 2,429
  • 1
  • 29
  • 34
28
votes
4 answers

How to make sed remove lines not matched by a substitution

I basically want to do this: cat file | grep '' | sed 's///g' without having to write the expression twice: cat file | sed 's///g' Is there a way to tell sed not to print lines that…
Ropez
  • 3,485
  • 3
  • 28
  • 30
26
votes
3 answers

why process substitution does not always work with while loop in bash?

The process substitution works with filenames fine, e.g. both $ cat
John Smith
  • 1,027
  • 15
  • 31
25
votes
4 answers

VIM, Run a command on multiple files

I have a bunch of sass files and my designer used the wrong syntax. I wanted :margin-top 1px but he did margin-top: 1px So I easily wrote a sub command: :rubydo sub! /([\w-]+):/,':\1' So that works and fixes all the colons and moves them in the…
Andrew WC Brown
  • 2,240
  • 5
  • 22
  • 24
25
votes
6 answers

How can I combine multiple nested Substitute functions in Excel?

I am trying to set up a function to reformat a string that will later be concatenated. An example string would look like this: Standard_H2_W1_Launch_123x456_S_40K_AB Though sometimes the "S" doesn't exist, and sometimes the "40K" is "60K" or not…
24
votes
6 answers

Bash bad substitution with subshell and substring

A contrived example... given FOO="/foo/bar/baz" this works (in bash) BAR=$(basename $FOO) # result is BAR="baz" BAZ=${BAR:0:1} # result is BAZ="b" this doesn't BAZ=${$(basename $FOO):0:1} # result is bad substitution My question is which…
Matt
  • 8,367
  • 4
  • 31
  • 61
23
votes
3 answers

shell string bad substitution

I'm new to shell programming. I intend to get directory name after zip file was extracted. The print statement of it is $test.sh helloworld.zip helloworld Let's take a look at test.sh: #! /bin/sh length=echo `expr index "$1" .zip` a=$1 echo…
cattail
  • 337
  • 1
  • 3
  • 9
23
votes
4 answers

Substitutions inside links in reST / Sphinx

I am using Sphinx to document a webservice that will be deployed in different servers. The documentation is full of URL examples for the user to click and they should just work. My problem is that the host, port and deployment root will vary and the…
Martin Blech
  • 13,135
  • 6
  • 31
  • 35
21
votes
3 answers

Default substituting %s in python scripts

Sometimes in Python scripts I see lines like: cmd = "%s/%s_tb -cm cond+line+fsm -ucli -do \"%s\"" Where is the %s in the above line substituted? Does Python have some stack of strings and it pops them and replaces %s?
prahallada
  • 11,741
  • 4
  • 16
  • 6
21
votes
7 answers

Substitute the n-th occurrence of a word in vim

I saw other questions dealing with the finding the n-th occurrence of a word/pattern, but I couldn't find how you would actually substitute the n-th occurrence of a pattern in vim. There's the obvious way of hard coding all the occurrences like…
Gaurav Dadhania
  • 5,167
  • 8
  • 42
  • 61
21
votes
1 answer

deparse(substitute(x)) in lapply?

I would like use a function that uses the standard deparse(substitute(x)) trick within lapply. Unfortunately I just get the argument of the loop back. Here's my completely useless reproducible example: # some test data a <- 5 b <- 6 li <-…
Matt Bannert
  • 27,631
  • 38
  • 141
  • 207
20
votes
2 answers

vim replace character to \n

I need replace all ; to \n , but :%s/;/\n/gc not works
guilin 桂林
  • 17,050
  • 29
  • 92
  • 146