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
0 votes
0 answers
5 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 ...
  • 79
2 votes
1 answer
98 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 ...
  • 21
0 votes
2 answers
49 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
182 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
455 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 ...
  • 185
1 vote
0 answers
46 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
275 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
106 views

Evaluate a boolean expression as a string

Here's my code to evaluate a boolean expression: ...
  • 185
2 votes
2 answers
590 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 ...
  • 151
2 votes
1 answer
82 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 ...
  • 187
2 votes
1 answer
81 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 ...
  • 185
3 votes
1 answer
62 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
122 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 ...
6 votes
1 answer
298 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, ...
  • 205
3 votes
3 answers
166 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 ...
  • 362
2 votes
1 answer
61 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
35 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
68 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
100 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 ...
  • 71
2 votes
1 answer
65 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
138 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
167 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
24 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 vote
2 answers
37 views

Function that get 3 word for strings, than combine them to 1 string and finally print the string in reverse

I'm learning C and I got a task to make 3 function. The first get 3 addresses of string, get 3 words from the user, and enter into the addresses. The second get the 3 addresses of string and combine ...
3 votes
1 answer
160 views

Applying a cost function to a string based on a pattern string

I have a cost function Cost_Func(pt,STRING) that calculates value in a specific way based on the given pattern string pt and ...
  • 133
4 votes
6 answers
1k views

Reverse string with identical spaces as in original String using Java

This is interview question Reverse string with identical spaces as in original String using Java For example Original String : best in the world and is greatest and is making sure the world goes well ...
5 votes
2 answers
607 views

Count each word within a string

I am looking for a solution with fewer lines of code. This is code that is working perfectly, but I think I typed too much for this algorithm. If I did something wrong, feel free to tell me the error. ...
3 votes
1 answer
55 views

Transform textarea input into camelCase

The code below transforms the text area's input to camelCase. I am wondering if this code is considered correct to write in terms of performance and readability and if not, what are your improvements? ...
  • 51
3 votes
1 answer
148 views

Longest Palindromic Substring | Python Code Giving TLE

Problem Statement Given a string s , return the longest palindromic substring in s. Constraints ...
2 votes
1 answer
63 views

String / Char Vector Concatenation Performance Comparison in Matlab

Considering the suggestion of using modern string arrays instead of char vectors proposed by Cris Luengo, I am trying to make a code snippet for performance comparison of these two cases. The ...
  • 3,596
1 vote
1 answer
80 views

Adding string to a text file without duplicates

I have a function below, store_in_matchid_file, and it adds certain strings to a .txt file as long as that string doesn't already exist in the file. However that ...
  • 27
11 votes
4 answers
2k views

String formatting in C++

To develop my understanding of C++, I've written an overload function that allows users to use & to insert strings within other strings (denoted by a ...
  • 9,652
0 votes
1 answer
65 views

Function to perform a logical NOT in a string

I am using "tinyexpr", a cute library that can solve mathematical formulas in a string and I extended it such that it does logical operations with two operands as well. However I wasn't sure ...
  • 1,375
1 vote
1 answer
34 views

Rust program to print citations in Chicago author-date style

I have written a Rust program that lets you input a citation's metadata in a Bibtex-like format and generates a bibliography entry formatted in Markdown that conforms (more or less) to the Chicago ...
  • 207
0 votes
1 answer
79 views

Integer array to string

This function creates takes an int * buffer and creates a neatly formatted string (useful for printing the contents of an array). Is the code easy to follow? Is it ...
  • 155
1 vote
1 answer
127 views

Split large strings into parts by last index of character and by max length

This is my method to split strings into parts by last index of character and by max length, the rationale for this method is because I have to send, in a payload via ...
  • 135
0 votes
1 answer
54 views

Excessive space C++ string [closed]

Extra gaps A string is given. Write an application that will remove all extra spaces from this string. A space will be considered superfluous if: it is at the beginning of the line, before the first ...
  • 1
2 votes
1 answer
274 views

Split string by last occurence of character within a range

So I would like to split a string in two by the last space within the first 40 characters, the best solution I could think of: ...
  • 135
2 votes
1 answer
78 views

Text splitter using Regular Expressions in Python

I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list. I had an idea ...
2 votes
1 answer
43 views

Modify a string by identifying a substring, and replace it and the characters following it with a newly computed substring

I'm working on a string manipulation code in C++ for my internship project, where I have to find a substring within a string and essentially replace it and some characters following it with a newly ...
  • 29
5 votes
0 answers
128 views

A POSIX getdelim() and getline() implementation for MSVC

Tired of always having problems in reading arbitrary length lines from file under Windows, I tried to write a POSIX getdelim() and ...
0 votes
1 answer
33 views

OAuth implementation for Puredata

I am managing an OAuth implementation for Puredata (Pd), which is written in C. OAuth can accept RSA keys, but Pd cannot send messages with newlines, so placing private keys will come as a list of ...
  • 155
0 votes
0 answers
54 views

Checking if the string has any characters present in a list of chars

I have this requirement to find if the input string has any restricted characters. The restricted characters are stored in a HashSet. There are totally 1351 restricted characters are present in the ...
0 votes
2 answers
81 views

Slice function for C

I am trying to create a non-generic slice function. I want a 'view' not a copy. The scan_from arg is so that successive calls ...
  • 505
3 votes
2 answers
105 views

Generic splitting in Haskell

I am new to Haskell and took it upon myself to make a simple generic list-splitting (e.g. string-splitting) function: ...
1 vote
2 answers
82 views

Transforming a string by combining same duplicate characters

I'm solving a programming puzzle that requires to transform an input string by replacing pairs of duplicate consecutive characters with an "incremented" character, recursively, e.g. "...
21 votes
6 answers
8k views

I created something much faster than a std::string

I've recreated std::string in a way that might be faster. System Features: Much faster than std::string. Easy to use. It was designed as part of a large database ...
2 votes
1 answer
84 views

Golang solution to CTCI 1.2: Check whether two strings are permutations of each other

Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...

1
2 3 4 5
58