Questions tagged [strings]
A "string" is a sequence of characters typically representing a unit of human-readable text. Questions on this topic deal with processing strings in programs, and how various languages and environments define and manipulate strings.
202 questions
1
vote
1
answer
192
views
Data structure for grouping strings in a collection when they share common substrings [closed]
I am looking for a data structure and an algorithm to manage a dynamic collection of strings, but grouping strings that have a substring in common. I try to describe it through an example.
@Christophe:...
1
vote
3
answers
315
views
To enforce column limits on long strings? [closed]
We're trying to update our style guide (using google's guide as a starting point) and I'm currently in the middle of a debate with my colleagues about column limits. I believe we're all in agreement ...
1
vote
3
answers
171
views
How to link many large strings in a maintainable way
I'm developing an app that will work as a troubleshooter. In this, I want to ask the customers only relevant questions instead of giving them an exhaustive list.
Every option they choose will have to ...
6
votes
3
answers
2k
views
What is the benefit of caching a hash value in a string object?
I made a patch to a programming language run-time to cache the results of hashing a string in the string object, so that it is just retrieved the next time it is required.
However, I'm not convinced ...
-1
votes
3
answers
440
views
Is there a text distance (or string similarity) algorithm which accounts for the distance between characters?
I'm interested in finding a text distance (or string similarity) algorithm which computes a greater distance (or lower similarity) when characters are further apart.
For example, I want the distance ...
-1
votes
1
answer
1k
views
Will conversion of a string to a list, and vice versa count in time complexity?
Assume that there is a question where a string needs to be passed. Some modification needs to be done on the string and then returned back.
For the programming languages like C where a string is a ...
1
vote
2
answers
407
views
(Algorithm) Maximum Binary String After Making Changes
I am given a binary string binary consisting of only 0's or 1's. There are two allowed operations (can be re-used any number of times):
Operation 1: If the number contains the substring "00",...
1
vote
3
answers
478
views
Algorithm – Number of strings containing every string of a given set a strings
I have a given set S of strings, and a length l, and I am looking for the number of strings of length l that contains every string of S. A naive approach would be to generate every string of length l (...
10
votes
0
answers
266
views
Is there any guideline from Unicode on how to deal with graphemes that have no base character?
A valid sequence of code-points can begin with one or more combining mark, which form a grapheme cluster that has no base glyph.
I'm unsure how that should be handled, if at all.
For example, consider ...
1
vote
3
answers
2k
views
Comparing whether two very large text contents are different or not efficiently
I have a MySQL database with a column Body MEDIUMTEXT. Until now I used to only store the contents into it. There was no update option for the users of the application. Now, I wanted to add an update ...
-2
votes
1
answer
4k
views
How to identify encoding of a text string? [closed]
I guess most of you already met them. You get them from your data sources, see them in your logs, or in the output from your legacy systems. Some strings you can't really read.
To derive any useful ...
4
votes
1
answer
3k
views
Managing const strings in a Rust project
I'm looking for a way to manage constant strings in a Rust project. The hope is to manage my strings from a single file and avoid having the same string literals all over the place in the project.
...
3
votes
1
answer
2k
views
Should "NaN" default to SNaN or QNaN
I created a function to read floats (IEEE 754 binary 32-bit) from strings, for developers. I have everything finished and working perfectly, except i'm wondering if a user/or programmer enters a ...
1
vote
3
answers
4k
views
Find longest word in a string: are any of these algorithms good? [closed]
I'm trying to find the longest word in a given text, but it has to be done "old school": without using split, enumerate, etc. (I'm using Python but what I'm looking for is more of a ...
-4
votes
1
answer
124
views
What happen to string.ToCommonSenseCase()?
I'm very confused about this. In most programming languages, there are string.ToUpperCase(), string.ToLowerCase(), sometimes Capitalize() (which capitalize the first letter of the string), even ...
2
votes
4
answers
1k
views
What is a good place, in OO, to store a string that is used many places?
I have a string that is used in a few places.
string portalLoginPath = $"{Request.Scheme}{Uri.SchemeDelimiter}{Request.Host}/Account/Login";
I was thinking of creating a static class with a string ...
0
votes
1
answer
709
views
Subdomain matching
I am working on a small plugin for a DNS server. I have a static list of domain (sometimes subdomains too) names:
gaming.xyz.com
facebook.com
mail.example.com
blog.example.com
I want to check if a ...
12
votes
4
answers
2k
views
struct with nonsensical default value
In my system I frequently operate with airport codes ("YYZ", "LAX", "SFO", etc.), they are always in the exact same format (3 letter, represented as uppercase). The system typically deals with 25-50 ...
5
votes
2
answers
1k
views
How the rope data structure works when doing syntax highlighting
I am looking into the Rope Data Structure, used by some text editors like the xi editor.
I get the basics of how it works, and have seen some sample implementations such as here or here. But I am ...
2
votes
4
answers
3k
views
What is the optimal way to perform 5000 unique string replace functions in terms of performance?
Restructuring some code, and the way I built it up over time has portions that look something like this:
s.replace("ABW"," Aruba ");
s.replace("AFG"," Afghanistan ");
s.replace("AGO"," Angola ");
s....
0
votes
2
answers
11k
views
changing the value of String object in java
I have to set the value of a string object "result" depending on the results of different methods and different if/else conditions. In the end, there would be one (last value set) in the string that i ...
-3
votes
1
answer
322
views
Creating String with equal operator vs new operator? [closed]
I have seen most of times developer declares the string in below fashion
Approach 1:-
public void method1(){
String str1 ="Test";
}
Approach 2:-
Per my understanding better approach will be
...
6
votes
1
answer
4k
views
Why doesn't Swift allow Int String subscripting and integer ranges directly?
If I have a string:
let str = "Hello world"
It seems quite reasonable to be able to extract a character:
let thirdChar = str[3]
However, that's not legal. Instead, I have to use the extremely obtuse ...
0
votes
1
answer
148
views
Simple algorithm for computing an orderable value from a string
I would like to compute a numeric value for strings containing only /[a-z0-9]/i (ignore case). Later, I want to use this value for sorting rows. For this post, I am ignoring number also.
My thinking ...
6
votes
2
answers
4k
views
Detecting plagiarism – what algorithm?
I'm currently writing a program to read a body of text and compare it to search-engine results (from searching for substrings of the given text), with the goal of detecting plagiarism in, for example, ...