If I want do deparse the argument of a function for an error or a warning, something strange is happening if the argument is converted to a data.table within the function:
e <- data.frame(x = 1:10)
### something strange is happening
foo <-…
How can I replace all occurrence of user defined latex macros with their definitions?
For example, given this file
old.tex
\newcommand{\blah}[2]{#1 \to #2}
...
foo \blah{egg}{spam} bar
...
how to generate the file below in an automatic…
The substitute function in R creates a language object in the form of a tree that one can parse. How can I create the tree from scratch using list or else to then give it to eval?
# substitute gives a tree representation of the expression
a=1;…
The context
I have an Asp .Net web application with some pages that inherit from a base class "BasePage".
This BasePage class inherits from System.Web.ui.Page and I've overriden the Render method so that I can intercept the HTML stream before it is…
Is there a way to use relative paths in substitution instead of absolute ones?
I want to write this, which doesn't work:
service {
password = "qwerty"
url = "http://example.com?user=John&password="${password}
}
Works only this case:
service {
…
I run this substitution command on Ubuntu 12.04.
$ sed -e "s/([a-zA-Z0-9.-/\\ :]+)/\1/g"
However, the following error is raised.
sed: -e expression #1, char 27: Invalid range end
I can remember the same expression works on MacOSX.
Can you…
Let's say I have a word selected in visual mode. I would like to perform a substitution on that word and all other instances of that word in a file by using s//. Is there a way to use the highlighted text in the s//stuff/ part without having…
I'm trying this:
https://docs.docker.com/compose/environment-variables/#substitute-environment-variables-in-compose-files
and as stated by the documentation, this is my docker-compose.yml:
services:
web:
image: "${IMAGE}"
This is my .env.dev…
There's a file dummy.txt
The contents are:
9/0/2010
9/2/2010
10/11/2010
I have to change the month portion (0,2,11) to +1, ie, (1,3,12)
I wrote the substitution regex as follows
$line =~ s/\/(\d+)\//\/\1+1\//;
It's is printing…
How to replace a set of characters inside another string in Python?
Here is what I'm trying to do: let's say I have a string 'abcdefghijkl' and want to replace the 2-d from the end symbol (k) with A. I'm getting an error:
>>> aa = 'abcdefghijkl'
>>>…
how to call a function from the substitute string in vim? When i have:
%s/regex/string/g and i want the group as argument and replace it with the return value of the function:
%s/regex/call function(\1)/g so the group #1 will be the argument of the…
I have a list of tweets, many of which contain emojis that need to be removed. What would be the most effective method for doing this in R?
I have tried the following method which is supposed to substitute all words beginning with "\" with a…
Given a set of regular expressions, is there a simple way to match multiple patterns, and replace the matched text according to the pattern that was matched?
For example, for the following data x, each element begins with either a number or a…
I'm trying to change uppercase to lowercase using string replacement in bash, but i'm getting a bad substitution error.
> a=HEY
> echo $a
HEY
> echo ${a,,}
-bash: ${a,,}: bad substitution
# desired output is hey
I've seen similar questions to…
I have Perl code:
my $s = "The+quick+brown+fox+jumps+over+the+lazy+dog+that+is+my+dog";
I want to replace every + with space and dog with cat.
I have this regular expression:
$s =~ s/\+(.*)dog/ ${1}cat/g;
But, it only matches the first occurrence…