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
0answers
39 views

Performance: Use plain for loops to look for (existence of) string in string array?

I timed a few ways to look for a string in a string array (with 82 elements in the example) in a case sensitive manner plus ignoring case. I am kind of suprised, that the plain for loops are faster ...
-4
votes
0answers
21 views

STRING REVERSAL in PYTHON ( without using inbuilt functions) [closed]

WHAT IS WRONG WITH THE FOLLOWING CODE? IT' GIVING AN ERROR : STRING OUT OF RANGE ...
1
vote
0answers
19 views

Python put from txt file into array(multiple line) [closed]

Im kind new to programming and I'm working with STL files (in ASCII format). Basically I need to create an array of several lines, and in each line of that array I need to insert 12 positions of a ...
8
votes
2answers
321 views

Navigate objects from a path provided as a string

Recently I wrote a validator for some objects. To increase usability the validator gives the user hints on how to fix some of the found issues. Since the application is around something programmatic, ...
1
vote
2answers
79 views

increase speed & lower memory consumption of text normalization function

I'm trying to preprocess a large text document. I've written a text normalization function which takes a disproprtionate amount of time and memory. How can I format the function to lower these two? ...
3
votes
1answer
26 views

Convert a binary string, with each char separated by spaces, into a normal C string and print

This code is a purely for-fun project and it comes from this challenge at freeCodeCamp. This is simply an algorithm challenge which is usually meant for JavaScript, but I decided to perform in C. It ...
2
votes
1answer
28 views

Better filereading and print formating in R

I am a beginner using R and I am trying to solve some simple statistics problems and print the output. The following code takes in two datasets, computes the mean, ...
1
vote
2answers
65 views

Title Case function in C

I've written the following function in C which shall take as input a character array (decayed to a char * of course), and mutate the string into a title-cased string in the form "this is a string" -> "...
2
votes
1answer
34 views

Reading bytes between two quotes from a stream and decoding it to its appropriate character set [closed]

This is a component for a lexer which operates on a byte input stream that handles reading and decoding the contents of a string contained within double-quotes. The validity of the encoding is handled ...
12
votes
4answers
2k views

C Program which compares software version strings

I wrote the following C program to compare software version strings. Please provide any general feedback you'd like, but with special focus on error handling decisions, user input validation/...
3
votes
1answer
22 views

Check shell programs for portability

There are lots of shell programs that have /bin/sh as interpreter, yet use some features that are specific to bash or other popular shells. I have written a little ...
5
votes
2answers
157 views

Java Kata - String Calculator

I started learning Java recently. Currently I'm trying to improve my spaghetti code by solving different programming puzzles. It would be amazing if someone could give me feedback on the String ...
6
votes
3answers
1k views

Elegant solution to find a pair of Strings in a List [closed]

I'm new to Java8 and I must find an elegant solution to a problem. The problem goes I have a List of letters (of any size) that could contain any letter such as "A", "B", "C", "D", etc. I must check ...
4
votes
1answer
66 views

Clean up tags from a text

I need to generate random text for tests. I do that using alphanumeric characters and some special characters as well. For some special cases, I cannot generate the random text with tags. I have the ...
8
votes
3answers
1k views

Reverse each word in the string. All spaces in the string should be retained

This was part of a code challenge. I use them to help me learn c++/c# along with tutorials and guides. Basically I was taking a string... The quick brown fox jumps over the lazy dog. ...and ...
9
votes
4answers
941 views

Building string with max length

I need to run a evaluation for large (1 Million) number of components and build a string with error which has comma separated error codes. As the final string is to be persisted in RDBMS TABLE.COLUMN ...
4
votes
1answer
59 views

Determining whether a string is transformable into another by repetitively increasing its prefixes alphabetically

Here's Alice and Strings, a programming challenge on hackerearth: Two strings \$A\$ and \$B\$ comprising of lower case English letters are compatible if they are equal or can be made equal by ...
1
vote
1answer
54 views

Better to use string concatenation using std::string::operator+() or std::string::reserve() and std::string::append()? [closed]

I'm doing some code review and I saw something like the following: ...
0
votes
1answer
34 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
81 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
71 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
85 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
84 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
74 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
225 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 ...
8
votes
1answer
112 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
81 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
179 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
59 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"). I ...
6
votes
2answers
449 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
251 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
73 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
105 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
95 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 ...
1
vote
0answers
54 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
48 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 ...
14
votes
5answers
2k 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
142 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 ...
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
57 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
1k 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
108 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
100 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
38 views

x64 fasm strlen

This is a simple strlen function with registers documented: ...
1
vote
2answers
145 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 ...

1
2 3 4 5
52