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.

learn more… | top users | synonyms (1)

0
votes
0answers
5 views

Replacing data in a .csv file

The code works well and does what I intend for it to do. In essence, it opens a file referenced as 'resource'. This is a .csv file. I then searches for the keys in the dictionary and for each key that ...
-1
votes
0answers
16 views

Simple C program that reads a name, print last-first name format [on hold]

I'm writing a program that (as the title explained) reads a string (name and last name) and print it out in last-first name format. Example: Input: James Bond; Output: Bond, James. I haven't ...
6
votes
3answers
161 views

Replace spaces with '%20'

This is my attempted solution to Question 1.3 from "Cracking the Code Interview", 6th ed. Question: Write a method to replace all spaces in a string with '%20'. You may assume that the string has ...
11
votes
9answers
758 views

Simple string inverter program

I am currently studying c programming, but I'm at a very basic level. So for practice I made a program that reads a string and inverts it. I want to know if the code is readable and how I can improve ...
-1
votes
1answer
51 views

Custom currency format

I have the following code for currency formatting ...
4
votes
1answer
38 views

strncpy To strcpy Equivalence

I have this ugly function, and I feel that the entire strncpy should just be an strcpy: ...
5
votes
3answers
424 views

Checking if string characters can be arranged to form another string

I am working on a code project that checks if all the characters in str1 can be arranged to form another string (str2). If all ...
2
votes
2answers
39 views

Count overlapping substrings

I'm looking for feedback on the actual logic of this simple python 2.7 script. The automated grader passed it, but I expect it could be make more 'pythonic'. It was written for homework, and some of ...
4
votes
1answer
96 views

Parsing a string to extract values

I am writing some C# that will be running on Linux and will extract values from a kernel generated system file that represents readings from a sensor. The file contains two lines of text, and I have ...
11
votes
1answer
78 views

Glue Shredded Pieces (CodeEval)

I have solved problem 185 on CodeEval, Glue Shredded Pieces. The solution got a 100% score on all tests (edit: see comments), within the allotted time and memory constraints. I'm looking mostly ...
1
vote
1answer
46 views

Collating creature descriptors spread across multiple stanzas

I have been using Python for only a few days, so I am trying to learn about some best practices. An explanation of what this code is supposed to do is at the bottom of this post. It is an exercise to ...
5
votes
3answers
416 views

Write a method to determine if two strings are anagrams of each other

Is this code a good solution for the question, or is there a better way to do it? ...
5
votes
1answer
40 views

Remove duplicates from string without additional buffer

I completed an exercise from the Cracking the Coding Interview: Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or ...
8
votes
2answers
79 views

Random jagged int array generator

I've been working on learning about irregular arrays and thought making a generator such as this one would be a good exercise in applying what I have learned. The following class generates an array ...
7
votes
2answers
148 views

Removing curly braces and contents inside it

Lets say I have a string like this: string s = "A }{ B { C } }{" //Indexes: 0123456789ABCDE Just consider the indexes beyond #9 are 10,11,12,13, and 14 ...
0
votes
1answer
27 views

Replacing certain characters in a QString

This question is kinda similar to mine. However, I am using C++ with Qt instead of C#. How would I efficiently and easily remove all accents and special characters like !"§$%&/()=? etc. from a ...
3
votes
2answers
42 views

String helper class

I have class with some basic string operations. Any suggestion to improve the class ...
2
votes
1answer
58 views

Searching a string for any permutation of words

Given a string and an array of words, return all indexes in string for which a concatenation of all words in the array, in any order (so ["eensie", "weensy", "spider"] has six orderings) can be ...
1
vote
2answers
91 views

Check if a word is before another

Let's consider a method like this: public bool IsWordABeforeWordB(string Text, string WordA, string WordB) { ... } By Word ...
0
votes
0answers
28 views

Special-case sprite positioning

I have several objects which are assigned a certain size and position, works fine. The only problem is that in certain special cases the item has to be positioned a bit to the left and be a bit ...
1
vote
1answer
26 views

Print values of an array while stripping out some parts of the string

Is there a more efficient way to run this? I am especially interested in a way which perhaps does not require a for loop... ...
1
vote
1answer
73 views

String compression implementation in C

I implemented basic string compression algorithm that uses the counts of repeated characters. For example: the string aabcccccaaa would become a2b1c5a3. What do you think about this, is there a better ...
5
votes
1answer
60 views

Yet another immutable string

I know, there are a few implementations of immutable strings out there, but my focus seems to be a little different. My goal was to have a type that provided value semantics, but didn't incur the ...
5
votes
4answers
76 views

Remove specified number of characters from a string

From an exercised in Kochan's Programming in C, following a chapter on C's null-terminated strings: Write a function called removeString to remove a specified number of characters from a ...
4
votes
3answers
64 views

Replacing multiple search strings simultaneously

A utility method StringUtils.replace to replace multiple search strings simultaneously. I'm looking for a review of any and all aspects, but especially: Is ...
1
vote
1answer
58 views

Extract numbers from a string-Javascript

Consider the following string in javascript: var string="border-radius:90px 20px 30px 40px"; I want to extract the 4 numbers from that string and store them in ...
4
votes
3answers
62 views

Use va_list to format a string

I wrote a function that basically works like sprintf, but instead returns the formatted string (std::string). I haven't worked ...
3
votes
4answers
91 views

isRotation and isSubstring method

I have written an isRotation function that calls on isSubstring only once(I am allowed to call it only once). I have implemented ...
3
votes
4answers
113 views

Cut excess whitespace from input and print to output

Title is pretty self explanatory, this program just takes in input (not from command line arguments), removes the extra spaces in the input, then prints that to output. ...
3
votes
2answers
72 views

Aho-Corasick for multiple exact string matching in Java

I have this program that compares performance of two algorithm for multiple exact string matching: Given a set of patterns and the text, find in the text all occurrences of any pattern. For example: ...
8
votes
6answers
855 views

Length of a C string, capped to some maximum

If I have a oneliner in C such as size_t maxSizeOf(const char *s) { return strlen(s) > M_MAX_SIZE ? M_MAX_SIZE : strlen(s); } would it be better to have ...
10
votes
4answers
493 views

Algorithm for simple string compression

I attempted a problem from the Cracking the Coding Interview book. The following input: aabcccaaa should give the following output: ...
4
votes
2answers
116 views

Balancing the server load

I've created a program that will take, a bunch of numbers from a range of 1 - 255, and then put them into 3 different strings(servers) equally. It does this by ...
6
votes
3answers
554 views

Checking if characters in a string can be rearranged to make a palindrome

Can I please have some advice on optimizing, cleaning up my code, and places where I could save space/time? ...
11
votes
5answers
549 views

isPermutation method

I wrote an isPermute method. Can I get some tips and advice on better coding style? ...
4
votes
1answer
47 views

Worst case runtime analysis of a string partitioning algorithm

Give all the partitionings of a string s such that every substring of the partition is a palindrome What is the time complexity of this solution? And, how can I improve my code overall? ...
5
votes
2answers
104 views

String merge sort in Java

This snippet is about sorting a set of strings using merge sort. However, this version is tailored for strings as it relies on lcp values: Given two strings \$A\$ ...
10
votes
3answers
210 views

Check for whether a string contains any duplicate characters

I am a new programmer and I want to know if I'm inheriting the right styles. I don't want to pick up any bad/amateur habits. Any advice would be much appreciated. This is an ...
6
votes
3answers
110 views

Adding a mix of strings and string arrays to an array

I have asked a very similar question on codereview before with great feedback - basically im writing a language and im adding a function to add any strings or string arrays to a string array using a ...
12
votes
5answers
725 views

Check whether string ends with string

I wrote the following to check whether a string ends with a second string. ...
3
votes
2answers
143 views

Determining if an std::string contains a numerical type

I recently came across this SO question asking for methods to determine if a std::string represents an integer. There is also this SO question for ...
2
votes
1answer
50 views

Writing strings to the screen over time

The following methods just write strings to the screen over time to make it look like a typing effect, instead of all at once. The only difference is the argument in the ...
5
votes
3answers
253 views

Java String iterations

I am working with some Java code. Basically I have a wrapper class that holds a string and implements some of the many useful python string methods in Java. My goal here is to implement the Python ...
8
votes
6answers
1k views

Custom algorithm for hashing and un-hashing password

I am attempting to create functions for getting an algorithm, hashing and un-hashing a string. As it stands, it works, and very well. But, I feel this is not secure enough and someone could easily ...
16
votes
7answers
1k views

Find the longest word's length

The challenge is simple: Return the length of the longest word in the provided sentence. The solution is just as simple: ...
4
votes
2answers
62 views

Finding max depth of nested parentheses

The following code finds the max depth of nested parentheses in the given string - for example, for {}{}{{}} it outputs 2. If the given string doesn't contain ...
11
votes
3answers
867 views

Safe strcpy implementation with C++

After reading this article, I've decided to take a crack at implementing a "safe_strcpy" function that would remove some of the errors that the author speaks about. Obviously, my ...
4
votes
2answers
231 views

Function to split either a string array or string into a string array

I am programming a language interpreter in c# recently and i have created a set of functions that receive either a string or a string[] and splits it by a received string. For example: with a string ...
5
votes
2answers
94 views

List all repeated substrings with a fixed length

While fiddling around, I've made a very simple and naive function to retrieve any repeated sub-string within a certain string. ...
8
votes
1answer
76 views

Address filter with PHP using regex

I developed a PHP function to get a not formatted address and split it in a street name and number. Following are some patterns of received addresses StreetName Number SrtreetName, Number Number ...