184,918 questions
-5
votes
0
answers
74
views
Java string not reversing correctly using loop [duplicate]
I am trying to write a Java program to reverse a string entered by the user.
Expected Output
Input:
"hello"
Output:
"olleh"
Actual Output:
The output is incorrect or sometimes ...
Advice
0
votes
5
replies
128
views
Best SQL Function for Text Filtering
I am examining a large data set on sports activities amongst a population of people and need to find all entries of the word "soccer."
What is the best SQL function to filter all entries ...
1
vote
1
answer
51
views
How do I check whether a string is zero-length in Meson?
I have a string-typed project argument and I want to conditionally execute some Meson code depending whether it is set to an empty string or not. How can I achieve this with Meson? I looked at the ...
-4
votes
1
answer
207
views
Getting weird results from java string codepoints on a windows machine [closed]
package edu.practice.zapper;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Base64;
import java....
Advice
0
votes
8
replies
217
views
How to find a substring within a string in C?
I'm a begginer in C, but i want to find for a word or substring within a longer string
#include <stdio.h>
int main() {
char string[] = "C is a programming language";
char word[...
Advice
0
votes
0
replies
27
views
In sieve filters, is it possible to split a string into a list of strings?
In sieve, suppose I have the following variable:
set "thevariable" "a bb ccc dddd eeeee ffffff";
Is there a way to split the value of this variable into the following list of ...
3
votes
0
answers
87
views
How to handle "False Positive" string matches in a state-dependent OCR engine (Chess Move Validation)? [closed]
Problem: I am building an OCR-based engine to digitize chess scoresheets using Python and python-chess. I use the Levenshtein distance (specifically Jaro-Winkler) to map recognized text (e.g., "...
0
votes
0
answers
175
views
libxposed API 101: "cannot find symbol" for getModuleContext() despite extending XposedModule
Suggested Answer:
Headline: Use getModuleApplicationInfo() instead of getModuleContext() in API 101
In libxposed API 101, the method getModuleContext() is indeed deprecated or removed from the base ...
4
votes
0
answers
189
views
How can I apply tail/tails to a string of text in a Unicode-aware manner?
This "warning sign" character, ⚠️, corresponds to the sequence of codepoints U+26A0 U+FE0F (if I understand correctly, it is ⚠ followed by a variation selector character), so I can render it ...
Best practices
0
votes
3
replies
99
views
Unescape string to get special character from user input
I have a user input as str in a CLI like using argparse:
python -m service.run --separator \n
When I collect the separator, I get the escaped version of the string "\\n", but instead I want ...
0
votes
1
answer
87
views
Swift string truncates / does not hold enough content [closed]
I am trying to build up something that uses wkwebview and javascript..So, I am having terrible issues with strings..
They are way too short, meaning that they don't have enough capacity. I have ...
-2
votes
1
answer
189
views
Implementation of std::string class members [duplicate]
class string {
struct long_mode {
size_t size;
size_t capacity;
char* buffer;
};
struct short_mode {
uint8_t size;
char buffer[23];
};
...
0
votes
0
answers
47
views
Does the direction of brackets need to be flipped in an RTL lexer
I am writing a compiler for a Hebrew based programming language, and I have been wondering if I need to flip the direction of brackets. When writing in an RTL editor, the shift+0 bracket correctly ...
3
votes
3
answers
121
views
Matching consecutive duplicate characters in a string in Google Sheets
I have a string like this: ippeʔɒɒf ɒʈ. Note the doubled ɒɒ and pp. I want to replace the doubled characters with only one of itself: ipeʔɒf ɒʈ. I would also like this regexp to apply to any ...
1
vote
2
answers
103
views
How to handle ClassCastException when trying to cast CLOB to String in Java?
I'm maintaining a Java application using Hibernate 5.0.7 to interact with an Oracle 19C database. The data type of remark attribute in orders table is CLOB, java.lang.ClassCastException: com.org.proxy....
Advice
1
vote
1
replies
80
views
Coq (Rocq) standard library function for converting nat to string?
I'm looking for a Coq function that converts a natural number (of type nat) to a string. I've found some code here that works, but I'd really prefer if there was a function in a standard library that ...
0
votes
1
answer
42
views
Define literal string macro from b2 jamfile
How can I define a literal string macro from my jamfile ?
so that I can use it like this:
std::cout << MY_MACRO << std::endl;
I would like to avoid resorting to macro stringification.
I ...
0
votes
2
answers
136
views
Why doesn't pandas.Series treat strings as iterables?
From the pandas documentation, while creating a Series, it can take the following input as data:
Array-like
Iterable
Scalar value
String is a type of iterable, but when I try to create a Series ...
Best practices
2
votes
3
replies
82
views
How to export struct.string into string array
Matlab has two ways how to store strings; either as character array foo='the text' or as a string array bar="the text". The problem starts when one tries to concatenate the arrays vertically,...
13
votes
6
answers
985
views
Splitting a string into tokens with several possible separators, using `std::ranges`
My goal is to split a std::string into tokens delimited by a list of possible delimiters/separators.
For instance std::string line{"\tSplit \t\t this sequence\t of tokens "}; must be ...
-1
votes
1
answer
102
views
Improving lookup time on Python dictionaries with string keys
I'm working on a project that involves generating random data according to a wide variety of specific distributions. The number of sample points to generate can go up to hundreds of thousands, ...
Best practices
2
votes
4
replies
72
views
How can I replicate the order by algorithm from SQL when all variables are equal?
I'm trying to figure out why a SAS script and this R script don't produce the same variables.
The SAS script attempts to directly pull native SAS files from the Wharton TAQ database while the R script ...
Advice
1
vote
8
replies
79
views
Searching for strings in multiple text files and outputting matched lines to a CSV
I have a folder full of hundreds of text files formatted like so:
holdrod =fl__2183_180325_0045
<bunch of data>
measburn_tot = 189.260915
<bunch of data>
I want to use ...
Tooling
0
votes
11
replies
126
views
Filtering an inconsistent string
I'm working on a project in which I need to filter out specific strings from an inconsistent API, where the strings are not always what I want. I need to filter out eligibility for different education ...
1
vote
1
answer
54
views
What explains the strange behavior of arguments in CMake macros (as opposed to functions)?
Here is a piece of cmake code:
macro(my_macro p)
message("--my_macro--")
message("p is: ${p}")
if(p) # <========================= (1)
message("\"if(...
0
votes
1
answer
145
views
Segmentation fault when implementing a strcpy-like function in C [duplicate]
I am trying to implement a function in C similar to strcpy, but the program produces a segmentation fault when executed.
The code below attempts to copy a source string into a destination string, but ...
0
votes
3
answers
135
views
Core dumped after copying string to 2D array
I want to add strings to a fixed 2D array.
I have a core dumped error when executing my addToList function.
The program passes the list pointer and the string to add as arguments. I then iterate ...
-1
votes
2
answers
254
views
how many objects will be created with keyword new in java? [duplicate]
I just saw a video that explains basic concepts about string memory allocation (video: https://www.youtube.com/watch?v=gp6NY01XFoE). In 3:00, he says that two objects are created (one in String Pool ...
0
votes
2
answers
165
views
Why did Rust choose not to implement Add<char> for String, while providing String::push(char) instead?
Basic Add operation does not work
let mut st: String = "".to_string();
st += 'c';
|
3 | st += 'c';
| ^^^ expected `&str`, found `char`
Push Operation works
let mut st: ...
5
votes
1
answer
156
views
Python -> YAML: the strings yes and no get quotation marks (but shouldn't)
Is there a reason why yaml adds single quotation marks around the words yes and no when I create a YAML file from a Python dict?
MWE:
import yaml
def yes_or_no(
word: str,
) -> dict:
...
0
votes
0
answers
62
views
How to Parse CalDAV REPORT XML Response and Extract iCalendar Data in Gleam?
I am building a CalDAV/CardDAV client for the Gleam programming language. I have a function which sends a REPORT request to the CalDAV server (Baikal in this case) with this body:
let headers = [
#(&...
Best practices
0
votes
8
replies
96
views
Java CLI Task Tracker project
I am building a Task Tracker CLI project, currently working on the CLI structure to accept user input. I have used a switch statement to receive input from args. The problem I have is that I have ...
1
vote
1
answer
130
views
binary string code note working with condition
I have a binary string, in that binary string there are many zeros with followed by a single 1, for example, "...
1
vote
1
answer
149
views
R Code to recognize speaker turns in verbatim records with inconsistent formatting
I am trying to perform text analysis on large character strings that include multiple different speakers. I need to create a dataframe of 2 columns, speaker and turn, which have the person speaking ...
2
votes
1
answer
79
views
faster methods to remove substrings stored in one column from strings stored in another column
hist_df_2["time"] = hist_df_2.apply(lambda row : hist_df_2['timestamp'].replace(str(hist_df_2['date']), ''), axis=1)
I tried this to remove the date part from the timestamp. However, for ...
Advice
0
votes
4
replies
103
views
convert a numpy array[N] of 'S{n}' to an array[2*N] of 'S{n/2}'?
I have some code where I read N strings of a given size n into an ndarray, which I would then like to cut in half to obtain a twice longer array of strings size n/2. Is there a numpy operation which ...
0
votes
1
answer
85
views
Handle string concatenation in worker code string
I understood that it's common sense to return the worker code as string but debugging and coding is a bit ackward this way. Such at this position, where I would like to concat several string to copy ...
-2
votes
1
answer
185
views
How to use strtok to separate into tokens and append to an array [closed]
I am working on a function where I will be recieving data from an SPI communication and then get the date/month/year from them
I have created a function to do the latter
void set_file_header(const ...
-1
votes
3
answers
109
views
sed outputs matching line twice
I want to delete all lines that end with OFF except if they contain override.
Input
1765193089 socket override DiningRoom/Socket/Work/state ON
1765206025 socket evening Hall/Socket/Lantern/state OFF
...
Advice
0
votes
2
replies
86
views
How to handle variable-length header values when parsing HTTP requests in Java?
I'm building an HTTP server and parsing request headers. My current code fails when the Host header includes a port number because I'm splitting on :.
Current Code:
String[] header = line.split(":...
0
votes
1
answer
97
views
Change micropython unicode notation from \xb0 to \u00b0 in string
I am using Micropython on the ESP32.
I have the following string, which includes the unicode character \xb0.
a = 'abc\xb0def'
First, I will need to change the notation to the \U00XX form, second I ...
1
vote
1
answer
136
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
254
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
129
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
89
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
75
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
148
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
123
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 ...
2
votes
3
answers
308
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....
-4
votes
1
answer
214
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" ...