184,970 questions
1
vote
2
answers
195
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
133
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: ...
4
votes
1
answer
119
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
50
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 = [
#(&...
-1
votes
1
answer
148
views
How to write the \U unicode notation in Python regex? [closed]
I'm trying to use the \U format in Python 3 but found the following error:
>>> import re
>>> p = re.compile('[\U+0041\U+0042\U+0043]')
File "<stdin>", line 1
p =...
Best practices
0
votes
8
replies
77
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
122
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
143
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
77
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
98
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
55
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 ...
-1
votes
1
answer
151
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
104
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
79
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
84
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 ...