184,990 questions
0
votes
1
answer
78
views
How to create 2 new columns in R (date difference + convert Seasons to minutes)? [duplicate]
I am new to R and trying to create two new variables from my dataset.
My data frame is called netflix and it contains these relevant columns:
date_added and duration
Example values:
date_added: "...
Best practices
2
votes
8
replies
181
views
What is the optimal way to define a global constant string in C++20?
I need to define several constant strings that will be used across an entire C++20 project.
I am considering the following options :
constexpr char[] str1 = "foo";
constexpr std::string str2 ...
3
votes
2
answers
82
views
How do these 2 string buffers interact? Why does the internal logger buffer append to the buffer i dynamically allocate in main
So, for context, I have started writing a small HTTP-Server for learning purposes.
Currently, I have 2 modules: server and logger. The server module uses the logger I wrote internally for logging ...
Advice
0
votes
2
replies
60
views
slicing html text based on length of plain text
I have a problem where I need to cut off text based on a max length. But the inputted string could be html a la <p>hello</p>. the html tags do not count towards the max length.
for example ...
2
votes
1
answer
55
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"\\\\&...
Best practices
0
votes
2
replies
118
views
What is standard practice for handling VBA fixed-length string data in binary files?
I'm quite frustrated trying to write to a binary file in Excel VBA. The issue is with fixed-length string data in a Type structure. (Note that my binary file requirements are that fixed-length string ...
1
vote
1
answer
109
views
Pandas converts Excel strings like ‘2004E205’ to scientific notation — how to prevent this
How can I handle string values that contain patterns like xxxE205 (e.g., 2004E205), which are used as unique codes in my company? I explicitly read the column as a string in pandas, but values ...
-1
votes
0
answers
37
views
How to handle non-numeric input when using scanner.nextInt() in Java [duplicate]
I’m learning Java and testing basic input handling.
I wrote the following simple program:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner ...
2
votes
3
answers
230
views
Why is a custom specialization of std::hash<std::string> allowed?
I implemented std::hash<std::string> in the usual way, by specializing the std::hash template. But then I realized that these should already be provided by the <string> header (https://www....
-2
votes
1
answer
179
views
How to create a dictionary where the keys are the alphabet (A-Z), and values are a letter from a string in Python?
I have to create a dictionary, where the keys are letters of the alphabet, and the values are the indexed letters of a given string.
Example:
Given the string "BDFHJLCPRTXVZNYEIWGAKMUSQO" ...
Advice
0
votes
3
replies
59
views
String manipulation: extract words under brackets
I'm not yet very familiar with the patterns in Lua's string.gsub function.
If I have a string like this:
Fishing Lure(+100 Fishing Skill)(1 hour)
and I want extract only the string "1 hour"...
0
votes
0
answers
56
views
Issue With Jsoup Document Selector
I'm using java spring boot and jsoup and recently I upgraded jsoup version to 1.21.1.
My code creates search query and searches for it in the document
Elements targetElements = document.select(...
-2
votes
0
answers
57
views
Writing an excel file in R based on the name of a string [duplicate]
If a list of multiple dataframes (ListA), I can write an excel file doing the following: -
write_xlsx(ListA, "Results_Up_Until_20_10_25.xlsx")
The problem with this that the date will change,...
0
votes
0
answers
77
views
RRuntimeError due to variable names when specifying R-style formula for ML model in python (pymer4)
I am trying to use the pymer4 package in python for Multi-Level Models, and I have to pass an "R-style formula specifying the model". I understand that it looks like:
target ~ varA + varB
...
Advice
1
vote
7
replies
102
views
Build string from
I have array of strings
$Emails = '[email protected]','[email protected]','[email protected]'
This array can contain from 1 to unlimited numbers of elements.
And I need to build a filter string from ...
3
votes
1
answer
104
views
Why does calling ToString give different results with a Double returned by CDbl and a Double returned by Double.Parse?
Demo code:
System.Console.WriteLine($"CDbl: {(CDbl("234.56"))} {(CDbl("234.56")).GetType} {(CDbl("234.56")).ToString("0.0")}")
...
0
votes
1
answer
91
views
How to split a shell command into tokens in a quote-aware fashion? [closed]
The task
Given the following string¹
one ' two 'three four
the required function should split it in 3 tokens (one, two three, and four), in agreement with how the bash shell does:
$ function ...
0
votes
1
answer
124
views
What's the idiomatic/correct way to split a string into its first word and the rest of the string? [closed]
tl;dr
Ideally, I'd want the following
"hello world" is split in "hello" and " world"
" world" is split in "" and " world"
"hello "...
3
votes
1
answer
132
views
Windows USB Driver refuses to accept my manufacturer string
I am homebuilding a USB driver on STM32. I have managed to get the device to enumerate which is awesome, but only when I disable all the strings (set all ID's to 0). Right now, when I set ...
-3
votes
1
answer
118
views
How do I only accept specific string input [closed]
I want to write a code that finds the derivative to any function and want to take a user input on what type of function they're inputting is. Essentially I tried to write a while loop that only accept ...
6
votes
2
answers
183
views
If misaligned loads are supported on my platform then why does address sanitizer complain of undefined behaviour?
I'm using the Stringzilla string library, which is supposed to be close to how std::string operates. It has a flag called SZ_USE_MISALIGNED_LOADS. By default it sets it to on, and it looks like this:
/...
5
votes
4
answers
344
views
How to detect use of std::string SSO (short string optimization)?
If I have a long string:
std::string data("This is a string long enough so that it is not a short string");
And then I have a view onto that string:
std::string_view dataView(std::begin(...
1
vote
4
answers
169
views
How to get from a url string the path to a file with a FOR loop in a Windows batch file?
Given is a string which is a url of a file, e.g. http://url.com/file.zip. I want to extract the path without the file name, i.e. http://url.com/.
My idea for doing this was to break down the string ...
-8
votes
2
answers
234
views
My code fails to compile with "no match for 'operator=='" error [closed]
I tried using the std::getline() function with a vector, and I want to make something that turns the following user input:
3
AA AA
BB BB
CC CC
into the following output:
AA AA, BB BB, and CC CC [...
1
vote
2
answers
95
views
Transforming a UTF-8 string in a const context
I have a function capable of translating UTF-8 characters into a custom 8-bit encoding:
const fn char_to_custom_encoding(c: char) -> u8;
I'd like to apply it at compile time to a string literal so ...
0
votes
0
answers
59
views
Powershell script to replace a single carriage return [duplicate]
I am importing a web order CSV file into our in-house database. Usually it's ok but, if the user enters special delivery instructions, the csv file includes the string "help.", followed by ...
2
votes
0
answers
77
views
Problem with characters and cmp in x86_64 assembly language (AT&T) [duplicate]
I'm having trouble writing what should be a simple character counting program. Here's the file with the .data section, as given by the author of Learn to Program with Assembly, which I'm following (I ...
1
vote
2
answers
148
views
How to show true string in Access VBA Listbox
I have here a listbox showing data from tbl2026Test table (with ID as its own autonumber) by a simple listbox rowsource code:
Dim statInProg, statPClarif As String
statInProg = "In Progress"
...
2
votes
2
answers
123
views
Pointers, referencing, and dereferencing static strings in assembly language
I'm writing a little toy program to try to help myself better understand this language (AT&T syntax, x86_64 assembly language). Consider this code, if you'll be so kind:
.section .data
mystring: ....
1
vote
1
answer
188
views
Format() Entire Strings (Rather Than Characters)
Background
VBA has a Format() function which converts any value to its textual representation. This is useful for numbers and Dates and times, but it can also be used on Strings.
Debug.Print Format(&...
0
votes
1
answer
169
views
Set placeholder in a String "equals" check
I've got two lists in my Java app: The first contains commands, the second the according valid replies, which I compare to the actual replies:
private final String[] commands = {"Do something&...
0
votes
3
answers
118
views
How to slice first char from all iterable records in a string (converted from list)
I'm trying to remove the first/last two characters of each iterable record in a string (which I converted from a list and split into separate lines).
newString = "\n".join([str(item) for ...
1
vote
1
answer
173
views
String manipulation in R, conditional capture and conditional append. ?regex solution
I am using hospital data. I want to make a regex expression in R and I am struggling to do this without using string manipulation outside of a single regex expression.
The string I want to search is:
&...
3
votes
1
answer
88
views
Replace part of strings with corresponding values from table in R
I have a list of file names that encode some information as a time stamp. I would like to replace the time stamp with the appropriate corresponding information, while retaining the rest of the ...
5
votes
2
answers
101
views
unable to remove leftover "()" string with get-childItem in windows powershell
I restored a large number of files in diverse folders from a hard drive, and they all included a string.
I removed this string in windows powershell using
get-childItem -recurse | Where {$_.name -like ...
0
votes
0
answers
37
views
How do I use str::split and str::split_whitespace in the arms of a match expression in Rust [duplicate]
I have some code that splits a string and then does some processing on each part of the string, before returning Vec of values based on each segment. By default, the code should split the string by ...
2
votes
3
answers
175
views
How to properly replace long strings in Perl
Let's say I want to replace every occurrence of 12345 in file1 with the contents of file2. The following code works:
use strict;
use warnings;
local $/;
open my $fh, 'file1' or die "$!";
...
0
votes
0
answers
140
views
Does accessing the contents of the string after calling reserve causes UB? [duplicate]
From another thread I found that
indeed allocates enough storage to hold at least n elements, but it doesn't actually fill the container with any elements
If elements are already allocated why ...
1
vote
2
answers
116
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
124
views
Slice the extension `'.txt'` from file names [duplicate]
I was trying to slice the extension '.txt' from some file names.
It look like the Python cut the last letter - before the dot- if its a t or x:
filenames = ["report.txt", "downloads....
0
votes
2
answers
73
views
Need to fix string in a single block of code DATABRIcKS
I am attempting to proper case the contents of a column that has various erroneous inputs. The code I used worked on everything except where the word is all caps.
I can't do "lower(initcap(field)...
3
votes
2
answers
122
views
How to remove the apostrophe from a string in VBA
I am trying to remove the apostrophe that excel place automatically at the beginning of a string, I wrote the code here below to delete the apostrophe. The code detects the char (') but did not delete ...
12
votes
2
answers
865
views
convert string with hidden characters
I have some character strings which I'm getting from an html. Turns out, these strings have some hidden characters or controls (?).
How can I convert this string so that it only contains the visible ...
0
votes
7
answers
239
views
How to split camelCase or PascalCase strings into readable labels in Delphi?
I'm working on a Delphi mobile app and want to convert camelCase or PascalCase identifiers into space-separated, human-readable labels.
For example this is my array:
const
ReadableIdentifiers: array[...
3
votes
1
answer
157
views
How to clean inconsistent address strings in Python?
I'm working on a web scraping project in Python to collect data from a real estate website. I'm running into an issue with the addresses, as they are not always consistent.
I've already handled simple ...
0
votes
0
answers
59
views
Dereference iterator and then iterate over dereferenced value [duplicate]
I have a piece of text with delimiters in it. I need to extract words from it and convert them to lower case. My approach is to use regular expressions to split the text and use transform to convert ...
5
votes
4
answers
245
views
How to efficiently swap two parts of string without allocation? [closed]
I have a long string. In the string, I have two non-overlapping parts. They can have a gap between them. The lengths can be different.
For example a string:
This is a "foo", that is a "...
0
votes
0
answers
51
views
Why does string match print True/False into output? [duplicate]
I have a test.ps1 PowerShell script with "a" -match "b"; inside.
I run it using powershell -ExecutionPolicy remotesigned -File test.ps1.
Why do I see False printed in console? (and ...
1
vote
1
answer
86
views
how to initialise a 2D array of Strings in Rust
I'm trying to make a 2D array of Strings using the ndarray crate..
use ndarray::Array2;
char_array = Array2::<String>::zeros((width, height));
Clearly, it doesn't work, so what's the ...
3
votes
1
answer
149
views
postgres: parameterized query with pattern matching
in node, i'm creating the following query:
let sql_query = "\
SELECT \
... \
WHERE \
FACILITY_ID = $1 \
AND (EVENT_START_TIME_UNIX_MS < $2) \
AND (...