Questions tagged [string-interpolation]

String interpolation is the replacement of defined character sequences in a string by given values. This representation may be considered more intuitive for formatting and defining content than the composition of multiple strings and values using concatenation operators. String interpolation is typically implemented as a language feature in many programming languages including PHP, Haxe, Perl, Ruby, Python, C# (as of 6.0) and others.

https://en.wikipedia.org/wiki/String_interpolation

1093 questions
-1
votes
1 answer

string interpolation with sqlite3 and Node

Somewhat new to this, but I'm having an issue inserting a variable into my sqlite3 query. I get the error { [Error: SQLITE_ERROR: no such column: shmee] errno: 1, code: 'SQLITE_ERROR' } where shmee in this case is req.body.username Not sure what I'm…
-1
votes
1 answer

Why can I access PHP objects inside a string?

This is some PHP code for rendering an HTML anchor element. Why does this: $archives .= " [List^]"; work…
Axonn
  • 10,076
  • 6
  • 31
  • 43
-1
votes
2 answers

Reading by scanf line by line

I need to use scanf to read a text file input into stdin. I want to read the text file line by line and then assign each values in the line to their values. This is the text file 38 5 35 3099 48 222 16 4 1 Ronaldo 2 33 2572 22 97 7 6 0 Neymar 1 38…
jingo
  • 13
  • 1
  • 2
-1
votes
2 answers

Ruby string interpolation

How do I insert #{stock_sym} into stock_price = dom.xpath('//*[@id="yfs_l84_aapl"]').first.content replacing aapl?
jmanikan
  • 37
  • 2
-1
votes
2 answers

Parse backslash escape with str_replace

Say I have a function templateMap which, for each subarray of $array, replaces every occurrence of @n (for some n) in the given $string with values from that subarray, returning the new array of subarrays. Also say that I want to allow the user to…
Chris Middleton
  • 5,654
  • 5
  • 31
  • 68
-1
votes
1 answer

Generate All Possible Matches of a Regular Expression

How can I derive all possible matches of a regular expression For example: ((a,b,c)o(m,v)p,b) The strings generated from above expression would be: aomp bomp comp aovp bovp covp b
-1
votes
2 answers

Run shell command with many arguments

I have a very long command with many arguments, and somehow it's not working the way it should work. The following knife command will connect to remote vCenter and create a VM called node1. How do I wrap the following command and run inside ruby? Am…
Satish
  • 16,544
  • 29
  • 93
  • 149
-1
votes
2 answers

python string interpolation syntax error

I am playing with the string interpolation and I keep getting the following and don't understand why I keep getting invalid syntax >>> import time >>> today = time.strftime("%A") >>> print "Today is %s." % today File…
user2757400
  • 45
  • 1
  • 8
-1
votes
2 answers

Call variable inside array element

Is it possible to read array element using variable? I'd like to set $vid in one place depending on the configuration, and then use multiple times i.e. $detailrow["customfields1"]; I want to do this: $vid = 1; $detailrow["customfields$vid"]; But no…
jakubplus
  • 307
  • 4
  • 17
-1
votes
1 answer

Interpolate json value from ajax call in jquery

I have an ajax call in jQuery which returns a set of values: p1, p2 ... pn. These contain strings of a path and filename for displaying images. ie the img src value. I want to loop through these n values ( i = 1 to n ) something like [pseudo] :…
Upland
  • 691
  • 3
  • 8
  • 18
-1
votes
2 answers

PHP: Interpolating a PHP variable in a string block

So, in Perl and PHP, you can produce a block of text using a number of the "<" symbols: Perl: return <Perl interpolates this properly TEXT PHP: return <<PHP does not interpolate…
Thumper
  • 525
  • 1
  • 6
  • 21
-2
votes
1 answer

clear Interpolation-only expressions are deprecated in Terraform warning question

We have been doing, node_selector = var.node_group != null ? { “${var.node_group}” = true } : null and in tfvars we will have, node_selector = “NODEGROUP2” And it works correctly. Tflint is throwing a warning on it as below, Warning:…
Simon
  • 111
  • 1
  • 9
-2
votes
1 answer

Please tell me how to print the alphabet in upper case when printing hexadecimal using Convert.ToString

output.WriteLine($"{Convert.ToString(num1, 16).PadLeft(width)}"); The above code outputs the integer converted to hexadecimal. The 'width' variable is a variable that takes a value from the keyboard to determine how to align the numbers. When…
-2
votes
1 answer

Why is my string interpolation not working

I used backticks yet the string interpolation is not working, what's even weirder is that it is sometimes working in other parts of the code. It's not working here let files = getFiles(`./commands/${category}`, ".js") But it is working here if…
Ancient
  • 41
  • 1
  • 5
-2
votes
1 answer

What does String.format() do inside the return statement of my code?

Please could anyone explain what's going on with the return method(String.format)? Also, I would like to know how does the code inside the last return statement works? import java.util.Map; import java.util.HashMap; public class RockPaperScissors…
Hubert
  • 19
  • 4
1 2 3
72
73