184,990 questions
Best practices
0
votes
0
replies
48
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 ...
0
votes
0
answers
33
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
1
answer
171
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" ...
0
votes
0
answers
47
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(...
0
votes
0
answers
50
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
99
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 ...
0
votes
1
answer
88
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 ...
3
votes
1
answer
100
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 ...
6
votes
2
answers
181
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:
/...
1
vote
4
answers
156
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 ...
1
vote
2
answers
94
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 ...
2
votes
0
answers
76
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 ...
2
votes
2
answers
121
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: ....
0
votes
1
answer
161
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&...
1
vote
1
answer
166
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:
&...
5
votes
2
answers
89
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 ...
2
votes
3
answers
167
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 "$!";
...
1
vote
2
answers
114
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="...
0
votes
2
answers
72
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)...
11
votes
2
answers
856
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 ...
3
votes
1
answer
152
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 ...
5
votes
4
answers
244
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 "...
1
vote
1
answer
85
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
0
answers
228
views
Passing strings between Excel and Delphi 12
I currently have a Delphi DLL which takes in 2 parameters as PChar and another parameter that outputs as a PChar to Excel. In Excel these are all string, but whenever I run the macro in Excel, my ...
2
votes
2
answers
100
views
How to return a String from swift to cpp caller
I am working on a C++ library with a Swift backend (the C++ code mainly serves as a bridge to Rust).
I have the following:
char* get_string(void* pBackend) {
Backend* backend = (Backend*) pBackend;...