Questions tagged [string-processing]
Use this tag when the presented code focuses on string manipulations (such as concatenation, splitting, and extracting parts of a string) or on analyzing and manipulating the contents of strings (e.g., searching, matching against a pattern, and encoding / decoding).
29 questions
5 votes
4 answers
491 views
Substitute patterns with values from lists
I was looking at a Stack Overflow question and got somewhat carried away with improving the solution, well beyond the scope of that question. In summary, we have a string such as ...
2 votes
1 answer
163 views
Huffman code builder in Java - computing prefix codes for arbitrary (generic) alphabets - Take II
Intro (This is the continuation of HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets.) (See the GitHub repository.) This time: I have fixed the misspelled ...
4 votes
2 answers
372 views
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
(See the continuation of this post at HuffmanEncoder.java - computing prefix codes for arbitrary (generic) alphabets - Take II.) I have this Java implementation of the Huffmann encoding. It looks like ...
4 votes
3 answers
494 views
A simple method for compressing white space in text (Java) - Take II
Intro In this post, I will elaborate on A simple method for compressing white space in text (Java). Here, I have incorporated some advice offered by Chris. Also, this version preserves a single new ...
5 votes
1 answer
542 views
A simple method for compressing white space in text (Java)
(The story continues in A simple method for compressing white space in text (Java) - Take II.) Intro Now I have that text space compressor. For example, ...
2 votes
2 answers
125 views
Checking for weak string isomorphism in Java
Intro I call two \$n\$-strings \$s\$ and \$z\$ over the alphabet \$\Sigma\$ weakly isomorphic if their character frequency multisets are equal. In other words, for an input strings \$s\$, we derive a ...
10 votes
3 answers
992 views
Checking for string isomorphism in C++
Intro This snippet is a translation of the Java version. Code string_util.hpp: ...
4 votes
1 answer
185 views
Checking for string isomorphism in Java
Intro Two \$n\$-strings \$s = \langle s_1 \ldots s_n \rangle \$ and \$z = \langle z_z \ldots z_n \rangle\$ are considered isomorphic if and only if there exists a bijection \$f\$ such that for all \$...
2 votes
0 answers
62 views
Funny time with DNA: a \$k\$-mer index data structure in Java, Take II
(See the previous and initial iteration.) Intro This time, I decided to pack the genomic data such that 4 nucleotide bases are encoded into a single byte. In other words, ...
4 votes
1 answer
111 views
Funny time with DNA: a \$k\$-mer index data structure in Java
(See the next iteration.) This time I have programmed a simple data structure called \$k\$-mer index. The actual word \$k\$-mer is a synonym of substring of length \$k\$. This data structure is built ...
5 votes
1 answer
345 views
Multiplying two large numbers whose digits you have in a string, in AEC compiled to WebAssembly
You can see it live here: https://flatassembler.github.io/multiplying-strings-aec.html ...
5 votes
2 answers
116 views
Simple Word-Based Text Truncator
I created a Python 3.11 utility that truncates an input string to a fixed word count—splitting on any whitespace, collapsing runs, and dropping trailing stop-words—so you get clean, concise snippets ...
9 votes
3 answers
1k views
A simple C++ function converting the environment variables in main() to an unordered_map
I had this program: ...
5 votes
2 answers
186 views
C++ arithmetic calculator built without resorting to tree structure as conventionally done, but by parsing input string and then std::stoi
Lately I came across a book exercise that asked to implement a calculator by resorting only to std::string manipulation. I avoided C++ streams as well, as they are ...
5 votes
1 answer
415 views
Converting a char string to wchar_t string based on a given toWideStr() starting point
I'm working on a legacy code base and I came across a method in which I wanted to remove the chance of swallowing an exception. In the following I want to walk you through the refacoring process, ...