1,144 questions
1
vote
2
answers
106
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
172
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
45
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
52
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
28
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
77
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
69
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
61
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
69
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
78
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
50
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
140
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
96
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....