Questions tagged [strings]

A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

Filter by
Sorted by
Tagged with
1 vote
1 answer
49 views

Do a thing with a derived string for a number of strings

I feel this should be possible more concisely, less code repetition, with a loop and a two-dimensional array or something. But not sure how exactly. Any best practice for review? ...
5 votes
0 answers
60 views

String literals concatenation with support for dynamic strings

I have implemented a function to concatenate string literals at compile time. Basic requirements: Very simple API. Can be used as a one-liner. Must accept variadic string literals. Highly optimized ...
2 votes
2 answers
73 views

Optimizing - formatting a person's name

I need to take a user's name and format it 'lastName, firstName middleName'. If firstName and middleName are not present then the comma should not be included with lastName. Below is what I came up ...
  • 31
5 votes
1 answer
93 views

C++ String Conversions using Iconv

Since charset conversions is so darn badly implemented and most standard options are deprecated I recently wrote a wrapper around iconv that converts from system narrow / multibyte character set to ...
  • 462
2 votes
3 answers
65 views

Resizable string object

...
6 votes
3 answers
138 views

Reversing words of a string without using inbuilt functions

I was wondering if I could reverse a string without using collections and in-built functions of string, Please do add your thoughts on the approach and if possible do share your way of the solution. <...
  • 61
2 votes
1 answer
65 views

Clean up improperly formatted phone numbers

This is a problem from Exercism here, the goal is to clean up badly formatted phone numbers. The rules are: If the phone number is less than 10 digits assume that it is a bad number If the phone ...
3 votes
1 answer
213 views

High performance 3 Way Quick Sort Implementation

My implementation of 3 way quick sort for strings. It supposed to sort very large set of 800,000,000 objects. This is why I added ...
  • 1,326
3 votes
1 answer
43 views

SImple Inverted Index

This is a simple inverted index I made. The goal is to: Read set of text files from a directory, docs Tokenize them Normalize the tokens by removing punctuation ...
0 votes
1 answer
68 views

Short Text Pre-processing

For educational purpose I am preprocessing multiple short texts containing the description of the symptoms of cars fault. The text is written by humans and is rich in misspelling, capital letters and ...
-2 votes
1 answer
101 views

Number Plate Generation Program, improvements?

I wrote a number plate generation program. The program generates number plates for a car registered with a specific Memory Tag and on a specific date. Number plates use the following format: (2 letter ...
1 vote
2 answers
146 views

Replacing banned words from a given text

The following algorithm is used to find a word from Blacklisted words in a string (called text) and replace these words with censored text, as shown in the example. Example: ...
0 votes
1 answer
58 views

Convert strConflictedYesReviewers data into a single object which is grouped by ownerid and make array of opportunityid

I get a dynamic string(strConflictedYesReviewers) which contains multiple user recordswhere each record is separated by semicolon and then each record represents ownerid and opportunityid separated by ...
  • 103
1 vote
3 answers
71 views

FileIO lines to String Converter

I think I made a good FileIO object because I can simply copy-paste whenever I need, however I wonder How I can improve my code. This code takes file path of the target file and turns every line to ...
  • 13
2 votes
4 answers
446 views

Creating storage path for file from first characters of a hash

I made the following function to create the storage path for files from the the first 5 characters of the file's hash: ...
  • 149
5 votes
3 answers
386 views

An immutable C++ string with ref-counting

Class intended to be used as main type in a key-value database where keys and values are strings. Searched features: It is a const char * Behaves like a ...
1 vote
3 answers
121 views

Convert camelCase function name to snake_case

I have the following code: ...
  • 11
5 votes
2 answers
908 views

Formatting Credit card names from API response

I have an API that returns the brand of a credit card. I want to make them look nice for my user (e.g. correct case and spacing). The possible options are amex, <...
  • 329
0 votes
1 answer
44 views

Protein Translation Learning Exercise from exercism.org

I'm learning Rust by solving exercises from different tracks on Exercism. The below code is an implementation of "Protein Translation" from the Python track. I split ...
  • 435
1 vote
2 answers
137 views

Mapping bunch of integers to some strings with less repetition [closed]

I have this switch case statement which maps an integer to a string. There can be multiple integers that maps to same string. objective here is to not to duplicate the string value and retrive the ...
  • 21
2 votes
1 answer
34 views

Optimising function to strip honorifics from names

Problem I have a list of around ~1000 honorifics, see below for a sample. Given an input string of a name, for example ...
  • 233
-1 votes
1 answer
55 views

Palindrome string program [closed]

...
1 vote
1 answer
53 views

Simple string comparison function

A small, simple yet always needed function to compare two strings for equality. ...
  • 1,538
3 votes
2 answers
203 views

Add two numbers represented as digit strings

This algorithm adds two numbers digit by digit using their string representations. I am wondering what the time and space complexities of the following algorithm are. In particular, I am wondering ...
-1 votes
1 answer
269 views

How to split a file with multiple lines into fractional array elements?

I have a file with content: 4;10;3;6;10 6;9;1;3;5 3;2;1;1;2,65 I need to split each line of the file into an fractional (double) array with elements as these ...
2 votes
1 answer
75 views

An evolutionary algorithm written in Java to crack an XOR cipher

Alright. So TryHackme is a website that tries to teach hacking with hands on labs. They have a room called JVM Reverse Engineering where the user gets to reverse engineer Java apps, and in particular ...
  • 101
3 votes
1 answer
164 views

C++ std::string implementation

Following is my simple implementation of the std string class. Please review my code and offer some advice. I want to figure out is there anything wrong with my code or is there anything I can improve ...
  • 41
0 votes
2 answers
64 views

Reversing a Python string using [::-1] [closed]

I'm learning how to reverse list and strings. Is there another way of reversing a string other than using [::-1] method? even if the other method is the long route i would much appreciate it ...
5 votes
4 answers
284 views

StringPool in C++

I wrote a simple string pool for my compiler in C++ and want to hear your thoughts on its design. String pool has 2 functions: intern and ...
4 votes
3 answers
522 views

Split string into same consecutive characters

Description Splits a string into a vector of strings that has consecutive same characters Examples in test cases below ("5500025" --> ...
11 votes
3 answers
1k views

Remove leading zeroes from the beginning of a string

I want to remove leading zeroes (for a big integer library I'm currently making) in numbers represented as char arrays. I chose assembly for speed, but in order to simplify making the algorithm and ...
  • 307
1 vote
0 answers
60 views

Application for "Good" and "Bad" word checking

This thread is a continue version of Find match words based on a list of words where I now have added Good word dictionary. What I am trying achieve here is that I want to check if a user has a given ...
3 votes
3 answers
344 views

Finding first unique character in string

Below is a solution I came up with (in C++) for an algorithm that is supposed to find the first character in a string that only appears once in the input string (the input string is guaranteed to be ...
1 vote
2 answers
146 views

Evaluate a boolean expression as a string

Here's my code to evaluate a boolean expression: ...
  • 307
2 votes
2 answers
640 views

Saving form data to a text file on server

I want to save simple string data as a simple text file (.txt) on the server (together with the IP), but I cannot find any clear guideline on how to do this correctly/efficiently/safely. (Maybe I'm ...
  • 153
2 votes
1 answer
119 views

Finding anagram groups using hashing and mapping the alphabet to random numbers

I was solving Group Anagram problem in leetcode. Link for the problem https://leetcode.com/problems/group-anagrams/ Below is the code which I wrote ...
  • 287
2 votes
1 answer
92 views

Increment a binary number represented as a string

I'm an amateur at assembly, but am trying to get better at it. For fun, I decided to write code that takes in a char array and increments the number represented in binary. Here are a few input-output ...
  • 307
3 votes
1 answer
163 views

TypeScript function to compare two arrays while ignoring case and whitespace

I'm just looking for general guidance on this short TypeScript function I implemented. Are there any glaring violations? Are there better practices for accomplishing this? Should I be using map/reduce/...
  • 203
3 votes
4 answers
327 views

Read arbitrary length strings in C

This is a classic thing to want to do since it's in C that one doesn't have the std::string of C++ and input of Python. I ...
7 votes
1 answer
335 views

Fastest function to `Remove Duplicate Lines` per each cell

The below function is used to Remove Duplicate Lines per each cell. It works without problem, but it is slow with a range of only one column and 17k rows. Actually, ...
  • 225
3 votes
3 answers
790 views

Discussing approaches for converting Enum to String

I need to convert the ENUM to a respective string value for which I came up with two approaches and I'm trying to see why would a second approach be better than the first one if even in terms of ...
  • 410
2 votes
1 answer
89 views

Improving the speed of one-hot encoding a list of strings

I've recently developed two functions to functions to essentially convert a list of strings that look something like this (these strings are 101 characters long in my case): ...
  • 123
1 vote
1 answer
67 views

Encode text to Baudot (teletype) code

After watching Computerphile videos on WW2 cryptography and radioteletype I decided to code a translator to Baudot code. I wonder if it can be somehow improved? ...
2 votes
1 answer
85 views

C dynamic strings

In the process of writing a compiler, I wrote this dynamic string library to help with keeping track of heap allocated strings and to have an easy way to format them. Note: The macros ...
3 votes
3 answers
126 views

C program that splits the string based on a character

I tried and made a program using my beginner knowledge of C to split a string into multiple sub strings. I just wondered how languages like Python and Javascript implemented the ...
  • 111
2 votes
1 answer
71 views

Remove duplicates from a Pandas dataframe taking into account lowercase letters and accents

I have the following DataFrame in pandas: code town district suburb 02 Benalmádena Málaga Arroyo de la Miel 03 Alicante Jacarilla Jacarilla, Correntias Bajas (Jacarilla) 04 Cabrera d'Anoia ...
  • 143
4 votes
2 answers
355 views

Add a number to a file name if does not exist or increase the number if it exist

I'm currently working on a solution to add a number to a file name if the number does not exist or increase de number by one if the number exist. For instance if you input "filename.jpeg" ...
  • 41
3 votes
1 answer
176 views

C++ String utility functions - Code check

I am trying to create a string class without std::string. Just for educational purpose. So I created some utility functions, and it would be very nice if you guys ...
5 votes
2 answers
2k views

C++ I wrote a simple and fast formatting library for strings

C++ FString A quick C++ formatting library I was working on a logging library, and needed some way to format strings quickly, simple and clean, so I wrote this library. This library is not the best in ...
0 votes
1 answer
29 views

How to speed up truncating text to specific word count in nim?

I have a web application, as part of it I regularly have to send out "overviews" of records in a database, which contain shortened excerpts of a description-text of that record. What the ...

1
2 3 4 5
58