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
1answer
37 views

Code to write a C template file [closed]

I am writing code to write a C template file; the executable takes two arguments (main) <file name> and ...
2
votes
2answers
105 views

Reverse string by separator

Here is problem: There is string (domain) divided by dots (like www.part1.partN.com) Need to build reversed by dot string (like ...
2
votes
1answer
75 views

Find all substrings that contain k specific characters in a string

Given a string, return the count of the number of substrings that contains characters A, B and C. Two substrings are considered different if the starting, ending or both positions differ. Example - s ...
3
votes
1answer
89 views

Find and return the earliest occurring word from a string which contains the most repeating letters

I'd like feedback on my solution to the outlined programming challenge (medium level). I've tried it fast in any way I know how to, but, what might be a more efficient and/or pythonic solution? [...
1
vote
2answers
85 views

A function to scan user input as string

I know that multiple functions are already available. However, I thought of writing my own because I wanted to learn the logic (and also because I thought there wasn't enough confusion :P). Please ...
3
votes
1answer
94 views

Run length encoding of an input string (Coderbyte 'Run Length' challenge)

I'd like feedback on my solution to the outlined (medium level) programming challenge. What might be a more efficient or Pythonic solution? The challenge as outlined by Coderbyte: [Run Length] (...
-2
votes
3answers
237 views

Find and replace a string in C/C++ without using standard library [closed]

I'm solving a problem with find and replace a substring in a string. I've solved it using Python with a couple of lines, in C++ using std library and now solved it with C by using allocation on the ...
9
votes
1answer
124 views

Tokenize a string with escaping

I am learning C and therefore decided to build my own, little shell. Currently I am concerned with input parsing. I want to split a line of text into tokens with delimiters. But it should be possible ...
2
votes
1answer
91 views

Resolve alias' original item using bookmarkData

This is my first Objective-C++ code, so I'm a bit lacking in the knowledge of methods. I need to resolve a macOS alias and get its original location. I have access to the C string, which is the file ...
7
votes
2answers
323 views

C++ wrapper for graphviz library

Background The code below is (obviously minimally) ripped out of a current live project. The project does reasonably sized data extraction, cleaning, analysis, clustering and visualisation (on a ...
2
votes
1answer
82 views

Parsing a string with specific pattern into json

I've a string as an input which is having some specific patterns and I'm trying to parse it into a desired json. Here is my code: ...
1
vote
1answer
60 views

Spotting prime numbers with use of limited prime numbers

I'm looking for general feedback as how to improve my code. I wrote the program starting out with no functions, making it very difficult to adapt. When I separated the program into functions it became ...
1
vote
1answer
69 views

Finding all alphanumerical words in a text line using std::string

Preliminaries I am working on a software that controls CAEN digitizer. The current step is to provide an ability to save/load configuration to/from an external source (hereafter - "config file&...
6
votes
2answers
451 views

C - manually parsing char* into integer

I'm trying to parse a char* into an int without using atoi(). I walk through the string, ...
6
votes
3answers
263 views

Validate parentheses “()” and “[]” are balanced

Firstly I was using regex to get if the number of parentheses in a string is balanced or not, but the performance was quite slow when any large string was passed to the regex. So I created this custom ...
3
votes
1answer
83 views

Censoring words in lua

(repost: https://stackoverflow.com/questions/59665338/censoring-words-in-lua#comment105491094_59665338, as advised) Im currently making a discord censor bot for my friend, and I was wondering if ...
1
vote
1answer
106 views

String Split a phrase into sentences

Hello this is a Console App(.Net Core) in Visual Studio 2019 and i am trying to split a string into sentences and then add them into a dictionary with Key the first word of the sentence and Value the ...
3
votes
3answers
103 views

Java regex and replaceAll to extract strings into objects

I have this method that creates book objects. I pass a list of strings (size 60000+) that contain the information of the book, the function then goes and extracts the information makes the book object ...
2
votes
1answer
88 views

Fast Stream Formatting Into String

I am trying to find a way to convert printable data types into a string in the fastest way possible. I originally read that a static variable of stringstream that ...
1
vote
0answers
26 views

Extracting English-French cognates from a messy .txt glossary

After using an online tool to convert a PDF glossary of English-French cognates to a .txt file, I wanted to write a simple script to extract the cognate pairs and save them to a CSV. I could then ...
5
votes
1answer
55 views

Minimum amount of spaces inserted in a given string, such that it gets composed only of elements from a given list

The Challenge Given a big string and a list of smaller strings, find the minimum amount of spaces that must be inserted between characters of the string in such way that it becomes composed only of ...
16
votes
6answers
4k views

Counting the number of consecutive 1's in binary

hackerrank.com Task: Given a base-10 integer, n, convert it to binary (base-2). Then find and print the base-10 integer denoting the maximum number of consecutive 1's in n's binary representation. ...
2
votes
1answer
35 views

Print a word with numbers substituted for characters

I wrote the following Python program to take 1 word from the user and return certain characters replaced by numbers. Given a dictionary, the program should print all possible combinations of the same ...
3
votes
1answer
205 views

Codewars: Sum Strings

Sum Strings Codewars kata. It's supposed to be able to handle big integers.   Question Given the string representations of two integers, return the string representation of the sum of those integers. ...
3
votes
1answer
46 views

PHP code structure for string manipulation tasks

I need to perform a bunch of string manipulation tasks on an original string, then output the final string. Best I could think of is extracting some functionality into functions. Any better way to ...
1
vote
0answers
67 views

String parsing algorithm in Rust

I have written a recursive parsing algorithm for strings with nested brackets (I needed it to solve a molecules to atoms task). I would love to see how I could make ...
0
votes
3answers
78 views

Convert an array of doubles to a concatenated Hex string

I'm working on a tool that converts data between two systems. System 1 presents me with arrays of latitudes and longitudes as doubles. System 2 requires an input of that array as a single Hex string. ...
2
votes
1answer
3k views

Generate Unique ID in C#

Objective To create a unique id with few characters as possible. Language: C# Engine Unity3D Target : iOS && iPadOS Scenario I found quite a few solutions from Stack Exchange but would ...
4
votes
2answers
179 views

String replacement with dictionaries — follow up

I was reminded by an achievement notification yesterday of this question of mine, posted nearly four and a half years ago. After reading through my own code and the review posted, I decided to re-...
4
votes
1answer
109 views

fasm convert hex byte to binary string

This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner? ...
3
votes
1answer
39 views

x64 fasm strlen

This is a simple strlen function with registers documented: ...
1
vote
2answers
153 views

Create secret messages

The problem is stated in Encrypt this!: Your message is a string containing space separated words. You need to encrypt each word in the message using the following rules: The first letter needs to ...
1
vote
1answer
69 views

Expand compressed string range

Say you have two strings: exp->aaccbb comp-> aa2bb This example will return true as there are 2 chars between aa and bb. I have written this code snippet and am wondering if there is a better way do ...
2
votes
1answer
51 views

Number of unique substrings of particular length of a binary string

Question: A binary string is given with only 0's and 1's. A number n is also given as the length of a sub string to be considered. It is to find the number of unique substrings. Here, n=3. My ...
11
votes
5answers
3k views

Python's .split() implemented in C

I'm new to the C programming language and I just made a basic version of Python's split() function using C. Note: A major functionality I chose not to implement is ...
4
votes
1answer
137 views

Printing a string in NASM Win16 Assembly

A small script that simply prints a given string. It's an improved snippet that combines some recommendations given in my post on string helper functions. ...
-1
votes
1answer
29 views

Provide one file where all error messages are defined in c++ [closed]

I would like to store all error messages in one file and call them for example with ...
4
votes
1answer
163 views

Two input file string comparison with C++. Large dataset 800+k. Harsh criticism welcomed

So I had a similar problem to this: https://stackoverflow.com/questions/39749430/import-huge-dataset-into-access-from-excel-via-vba/57995602#57995602 Although it was already answered, I provided a ...
8
votes
3answers
2k views

Generating a random string of 6 characters long in Python 3.6.2

I am learning Python, so pardon me if this is the very crude approach. I am trying to generate a random string using alphanumeric characters. Following is my code: ...
2
votes
1answer
55 views

Simple Email Subject Filtering (python)

This challenge took me forever. I spent a lot of time messing with regular expressions, but couldn't get it to work. I ended up coming up with this abomination. If anybody wants to take the time I'...
8
votes
1answer
70 views

strsepf() - Parsing string using strsep with a scanf-like interface

vstrsepf is string parsing utility function born from the idea of using strsep and strtol ...
7
votes
2answers
175 views

Simple IP address parser in C

I have written a C function to parse an IP address that should match the regular expression ^\d+.\d+.\d+.\d+ and nothing else. Additionally all bytes are limited to ...
3
votes
1answer
47 views

Small String hashing and compare

The idea is to convert first 8 character from the C string to uint64_t or uint32_t, then to convert to Big Endian. The value ...
2
votes
1answer
74 views

Guessing The Word

Made after seeing A Simple Word Guessing Game. Any code critique is welcome! ...
8
votes
3answers
277 views

“Fast strlen” in C using scalar bithacks

I've translated an implementation of strlen in x86 assembly to C and added alignment checking: ...
2
votes
2answers
58 views

Standardizes Rows of a Pandas.DataFrame Object

Please take a look at this little snippet of code and explicate on whether there are an efficiency enhancements that you'd make for it. It standards a row of a pandas.DataFrame by adding zeros to it ...
1
vote
0answers
47 views

How do I optimize memoization in order to find longest palindromic substring?

I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string. I have seen other questions on this problem that successfully solve ...
9
votes
2answers
236 views

python search replace and join with delimiter

I'm brand new and been going through some beginner code problems on checkIO. I finished this one today and am posting because I'm sure there is a much more elegant way to accomplish this, and I think ...
1
vote
1answer
166 views

InternedString as alternative to regular String

I need to use large strings as a dictionary keys, and I want to optimize the repetitive GetHashCode() and Equals() calls in it. ...
3
votes
2answers
195 views

Function to prompt and check user input

I'm trying to make a function that asks for a string input and then validates it. If the answer is not correct, the function asks them again for valid input with a while loop. In order to validate ...

1
2
3 4 5
52