1,148 questions
4
votes
2
answers
112
views
Trouble accessing a single element of an array in Powershell [duplicate]
I am attempting to use a single element of an array, when creating a string message, but it is using both elements, concatenated by a space, whether I use $myArray[0] or $myArray[1]...
# Multiple ...
2
votes
1
answer
62
views
backslash count in raw string interpolation in scala
I am using Scala 3.3.7.
When I do
val str1 = raw"\\\" // compile error: unclosed string literal
It is considering the \" as a single character.
But when I do
val str1 = raw"\\\\&...
0
votes
1
answer
103
views
Macro-free, MSVC-compatible std::format with check for extra argument
I use std::format in my logging, and it largely works great. However, std::format ignores extra arguments which I do not like. E.g., std::format("x = {}", x, y) compiles, so I want a ...
1
vote
2
answers
119
views
How to extract string between delimiters [duplicate]
Let's say I have a string:
$line = "name=""abc"""
I want to extract whatever is written within the quotation marks, like this:
[regex]::Matches($line,'(?<=name="...
2
votes
2
answers
180
views
How does interpolating a Perl constant into a string work?
I've just come across such usage of Perl constants:
use strict;
use warnings;
use constant PI => 4 * atan2(1, 1);
print("The value of PI is: ${\PI}\n"); # The value of PI is: 3....
1
vote
1
answer
56
views
Variable interpolation
I am trying to interpolate variables within an Ansible play. I have the following variables:
target_hostname
user_account
account_password
user_account_password is in a vault, and the variable is ...
0
votes
1
answer
62
views
Powershell: Using dimensions on Microsoft.Compute/virtualMachines metrics [duplicate]
I am following https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-compute-virtualmachines-metrics to export some metrics from Azure.
If build some code that ...
0
votes
0
answers
30
views
How can I find a translatable string by ID?
In the messages file of my multilingual Angular project, I have strings that only contain {$INTERPOLATION} and nothing else. These obviously don't need to be translated. They are mistakes, where there ...
2
votes
1
answer
83
views
Why use this syntax `{": "}` in React instead of just writing a colon
I saw this code snippet on the React dev page (https://react.dev/reference/react/memo#updating-a-memoized-component-using-state):
export default function MyApp() {
const [name, setName] = useState(''...
1
vote
2
answers
71
views
How to avoid memory allocation in catch block in Java Spring application (string interpolation)?
I am writing a Java Spring Boot (servlet) web-API application. There are repository classes in the application. Repository methods are written "from scratch" using Google Cloud Datastore API ...
1
vote
1
answer
68
views
Scala StringContext, how can I intercept expressions before evaluation?
I'm trying to use the Scala extensions to extend the String context to time the execution of a costly method And I came with this:
extension(sc: StringContext)
def timeit(args: Any*): String = {
...
0
votes
0
answers
70
views
Does string interpolation StringBuilder internally? [duplicate]
Note: this is not a duplicate of the question here. That one asks about string concatenation, which is different from string interpolation.
Consider this example of string creation in C#:
var str = $&...
-1
votes
1
answer
92
views
Terraform pass generated value as variable to User_Data
When deploying a Windows EC2 instance with Terraform, I want to create a user using the User_Data template. I am also passing a random_password variable to the template.
In the main.tf I have:
...
0
votes
1
answer
54
views
Dart string interpolation - invalid constant value
I am trying to follow this dart guide https://codelabs.developers.google.com/codelabs/dart-patterns-records#4 but ran into an issue with string interpolation.
I am totally puzzled why dart expects a ...
0
votes
1
answer
49
views
String interpolation returning unexpected result
I have a data class Shift:
@Serializable
data class Shift(
@SerialName("id") val id: String,
@SerialName("username") val username: String,
@SerialName("start")...
1
vote
1
answer
164
views
Lean4 string interpolation: Possible to format as hex?
Is it possible to customize the formatting when using string interpolation with Lean4?
More precise: I want to format using hexadecimal digits and add zeros as padding.
Minimal example
(Same example ...
19
votes
1
answer
2k
views
Escape braces in C# interpolated raw string literal
I need braces in a raw string literal that uses interpolation:
var bar = "Bar";
var s = $"""
Foo
{bar}
Baz
{{Qux}}
""";
Console.WriteLine(s);
I expect ...
2
votes
2
answers
114
views
Return placeholder values with formatting if a key is not found
I want to silently ignore KeyErrors and instead replace them with placeholders if values are not found. For example:
class Name:
def __init__(self, name):
self.name = name
self....
0
votes
0
answers
30
views
Vue text interpolation watches all elements?
Consider the following simple example.
Two counters are rendering, once with ref that gets updated every second and one static:
<script setup>
import { onMounted } from 'vue';
import { ref } ...
-6
votes
1
answer
187
views
Is there Swift 6 number formatting in string interpolation without "import Foundation"?
I like being able to do this:
print( "\("YYYY") \(454.90008)" )
but I want to do this:
print( "\("YYYY") \(String(format: "%.3f", 454.90008))" )
...
1
vote
2
answers
189
views
How can I combine unicode with string interpolation in Swift UI?
Hoping you can help - this may be a simple question.
I've got a list of the unicode values of emojis, and I'm trying to randomly display one. Here is where I'm hardcoding displaying the smiley:
...
0
votes
1
answer
105
views
How to forbid unknown parameter type in a scalikejdbc query?
When writing a string interpolation with sql"", how can I make sure that a Binder is present for a given parameter type instead of using the default that might not do what I want?
For ...
0
votes
1
answer
382
views
Terragrunt string interpolation on generate block
Having a hard time trying to make this work.
I'm trying to use the generate block to add a for_each and run the module multiple times depending on how much entries I have in the variable s3, but ...
1
vote
1
answer
81
views
How to combine string and array in string interpolation of ngfor in Angular
I have an array of objects, I would like to combine a string and an array while showing in ngfor iteration.
temp: [
{
"value1": "as",
"value2": "[a, b, c, ...
5
votes
3
answers
241
views
How can I write a happy birthday message in Ruby to put on a cake? [closed]
Original Question
My boyfriend is celebrating his birthday shortly and I am ordering a custom cake for him. I want to write Happy Birthday on it in a clever Ruby coding way. It will be on a black ...
0
votes
1
answer
661
views
Accessing signal array in the template
In the ServiceFile I have this signal:
answerSequence = signal<string[]>(['', '', '', '']);
I get this angular signal to my Component:
answerSequence = computed(() => this.questionService....
0
votes
0
answers
33
views
Perl how to read a line from a file with interpolation of embedded new line char [duplicate]
I am trying to print a line from a file with interpolation.
I have the following code:
open FH, "<", "file.txt";
my $line = <FH>;
print "line = " . $line . "...
2
votes
2
answers
125
views
Why does PerlCritic think my prototype is string interpolation?
I have code in a package (class) that has a sorting function with a prototype:
#!perl
package Foo;
use strict;
use warnings;
sub new {
my ($class, $value) = @_;
my $self = bless{}, $class;
...
1
vote
1
answer
290
views
Terraform doesn't let me join a string to a variable in for loop to reference another variable
I am sure this is not a unique requirement and I have delt with this type of issue using eval() syntax in few other programming and scripting environments.
My problem: I am trying to create a ...
0
votes
3
answers
103
views
Angular text interpolation (double curly brackets) not working, the values of the variables are not display
I want to display details of a student, but the values are not showing up on the app.
the component:
import { Component, OnInit } from '@angular/core';
import { Student } from '../student';
import { ...
-1
votes
1
answer
822
views
Why does Java's string templating use clumsy STR prefix? [closed]
Java finally supports string interpolation! I'm very happy about it. However, the syntax seems to me a bit clumsy
// string templating syntax from Java 23
String greeting = STR."Hello \{name}!&...
0
votes
1
answer
82
views
How jenkins resolves credentials without using string interpolation?
I was reading the Jenkins documentation and saw the following example:
pipeline {
agent any
environment {
EXAMPLE_CREDS = credentials('example-credentials-id')
}
stages {
...
1
vote
1
answer
36
views
Overriding HashMap.toString() in string interpolation contexts
I am trying to create a subclass of HashMap with its own string representation. I figured that I just needed to override toString() in the subclass:
class Foo extends HashMap {
String toString() {
...
2
votes
1
answer
84
views
Scala how to prevent empty lines in scala interpolated string template?
I have an object with some optional attributes which I want to list in a string template (In a sort of JSON way) If the attribute is None I don't want to see anything, if it is Non None I want to see ...
0
votes
1
answer
51
views
String Interpolation Issue Jupyter Notebook Pyspark
I am passing in the following as a query (.dbtable) to pyspark, running in jupyter notebook on AWS EMR.
num = [1234,5678]
newquery = "(SELECT * FROM db.table WHERE col = 1234) as new_table"
...
1
vote
2
answers
363
views
Is it possible to display Angular component using Angular Interpolation?
I have an Angular component that I depend on. This component has a getData method, then this method is called in the template of this component, and the result is displayed using Angular interpolation....
0
votes
1
answer
134
views
Groovy Yaml string interpolation with a list of maps
I am building a yaml string within Jenkins scripted pipeline that is parametrized.
The problem is that I get error interpolating string with a variable that is a list of maps.
I don't think I can use ...
0
votes
0
answers
44
views
Typescript Recursive String Interpolation
I'm working on a simple (but hopefully type-safe) system that represents timeSlots as strings.
// example
const t1 = "|mon::10:30|";
const t2 = "|fri::20:00|";
So far I have ...
0
votes
0
answers
27
views
invoke-webrequest fails with special characters [duplicate]
I am using a release pipeline to get a valid token, the client secret, and the user password via Azure Key Vault I am getting the client secret, and the user password. I did some tests and saw that ...
1
vote
1
answer
2k
views
How can I use a variable in a multiline string in Delphi?
Delphi 12 introduced multiline strings and I'm trying to figure out how it works, coming from a JavaScript background. There I can directly have variables in multiline strings such as:
const myName = '...
0
votes
1
answer
336
views
How to accept any variable type that can be used in SwiftUI Text view
I'm trying to create a reusable component for presenting a Swift collections OrderedSet into a SwiftUI List with delete, move and add handlers.
I would like to be able to pass in an OrderedSet of any ...
0
votes
3
answers
175
views
Ruby: replacement part include $1 $2 $3 and saved in a variable, but interpolation doesn't happen when using gsub
(a) the codes I wrote.
$str = '909090 aa bb cc dd ee ff 00 12345678 aa bb 12345678 aa bb cc dd ee ff 00 11 22 33 123456 FE 89'
puts $str
$str.gsub!(/\s+/, '')
search_1 = 'aa bb cc dd ee ff 00 (\S{8} ...
-1
votes
1
answer
1k
views
Jenkins groovy string interpolation using a combination of secret and non secret values [duplicate]
I have a shell command in my Jenkins script that uses string interpolation for non secret values as well as secret values.
For non secret values, you are expected to use double quotes and the string ...
0
votes
1
answer
308
views
powershell query with graph api
i'm trying to execute with powershell follow query:
$upn = "[email protected]"
$URL = "https://graph.microsoft.com/v1.0/users?$filter=mail eq '$upn'"
#Send Request
Invoke-...
0
votes
2
answers
122
views
Ruby Variable Interpolation in Array Names
I have a few similarly named arrays and I need to loop through the array names:
level_1_foo
level_2_foo
level_3_foo
level_4_foo
level_5_foo
I'd like to do something like the following where x is the ...
-1
votes
2
answers
65
views
Store a string interpolation template into a variable
Is there a way to store a string interpolation template into a variable in JavaScript and just call it as a function (or something like this)?
I would like to do something like this:
const myStr = `...
0
votes
1
answer
341
views
String interpolation, string formatting and null coalescing operator at once
I need this:
If the following formatted value is null, display N/A. Otherwise, display the formatted value. It needs to be with string interpolation. I tried to do something like nested interpolation:
...
10
votes
2
answers
11k
views
Is there a way to interpolate variables into a python string WITHOUT using the print function?
Every example I have seen of Python string variable interpolation uses the print function.
For example:
num = 6
# str.format method
print("number is {}".format(num))
# % placeholders
print(...
0
votes
0
answers
314
views
micronaut httpclient is replacing ampersands and equal signs in my url, but I dont want it to
Short Version
after reading the httpclient logs, I'm seeing that some characters are being url-encoded. I dont want that to happen.
Long Version
the url I'm calling is split into <base url>+<...
1
vote
0
answers
39
views
Output file not created as coded [duplicate]
Below is an extract from my script. The script checks if users are part of a specific AD groud then saves the users and the group they're a member of to a .CSV file.
function Process-UsersInOU {
...