A string is a sequence of zero or more 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)

6
votes
3answers
107 views

Pattern tokenization program

I am writing this program to try and get some practice at C++ and correct and proper styling. This code is meant to take user input from a pip and then run it through the program. The user enters a ...
5
votes
4answers
233 views

Counting the number of words in a string

I have written this program to count the number of words in a string. I have checked my program for the worst-case scenario. If any of you can find any cases for which this program doesn't work, ...
3
votes
3answers
100 views

Binary addition with strings

The following method will add two strings of any length as binary numbers assuming the characters 1 and 0. I made this for fun ...
4
votes
1answer
57 views

Generating the pretty bit at the end of a URL

I'm having a dip into F# and am attempting not to write it like it's C#. One area that bothers me is using members of System.String. These often need to be chained ...
-2
votes
0answers
29 views

understand operator precedence [migrated]

Was fixing bug in our code and found this weird function that was misbehaving: ...
6
votes
2answers
123 views

Output int from string input

This takes a string input like 1,2,3,4,5, splits it using , delimiter, converts each char to int and output it in a single line ...
2
votes
0answers
49 views

JavaScript function that returns all possible combinations of letters in a word

This is a JavaScript function that returns ALL the possible combinations of whatever word the user enters. I am looking to clean this code up a bit...any and all suggestions are welcome! ...
4
votes
1answer
76 views

Converting string array to string (and vice-versa) for storing via XML

I'm using XML to store data and I need to store a string array in it. The best way (that I can think of) to store a string array is by converting it to a single string. In order to do that, I'm using ...
1
vote
1answer
28 views

Identifying “Matching Bigrams” in Large Text Collection

I have a large number of plain text files (north of 20 GB), and I wish to find all "matching" "bigrams" between any two texts in this collection. More specifically, my workflow looks like this: for ...
6
votes
1answer
107 views

Finding common strings among 2 arrays of strings of length 1, sorted alphabetically in O(n) time complexity

The problem: Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. Return the count of the number of strings which appear in both arrays. ...
3
votes
2answers
84 views

Capitalize all words in sentence string in Ruby

I have created the following code: def LetterCapitalize(str) str = str.split(" ").each {|word| word.capitalize!} str = str.join(" ") return str end This ...
4
votes
1answer
80 views

Simple parsing for string formatting

Recently I submitted some string formatting and printing code (found here) that I wrote as an small exercise. It was implemented naively using string replacement. This time around I wanted to actually ...
12
votes
3answers
311 views

Memory-efficient string collection

My goal is to create a memory-efficient (immutable) collection of strings. The imagined use-case is checking for valid words in a Scrabble-like game. Wikimedia Commons has a pretty good summary of ...
5
votes
1answer
125 views

Replacing occurrences in NSString and NSMutableString

I ran it and it's working, but I just want someone to double check that I followed the directions. Any suggestions or corrections will be appreciated. Assume you have a ...
9
votes
1answer
145 views

Did I implement my string formatting code correctly?

As a small exercise I have written some string formatting and printing functions in C++11. I would like a bit of code review, not so much on the merits of using this over something like ...
8
votes
5answers
746 views

Splitting company name into 3 strings

I wrote an algorithm which should cut a companies name into 3 strings. Input: 1 String Output: 3 String. Conditions: String 1 2 and 3 shall not be longer then 35 signs. If the Input ...
3
votes
1answer
55 views

Haskell idioms in functions/arguments handling

I came up with this function rangedReplace as an exercice to use recursion and try different ways to make it work (I made at least 3 completely different versions). ...
2
votes
1answer
71 views

Tough List Comprehension Split Letters and Numbers

So, another challenge from my professor. I've finished it, but wanted to get some feedback, and see how other people might work this problem. Assume you have a string, such as "Hello 34215 World ...
2
votes
1answer
28 views

Trie SPOJ Problem - PhoneList TLE

In this problem you are given input of phone numbers and you are supposed to determine whether any number is the prefix of another. I have an addchild method that ...
7
votes
3answers
115 views

Compare string with wildcard string

I have the following function to compare a string with a wildcard string (containing ? and *), as C# doesn't seem to have a builtin function to do it. ...
2
votes
0answers
14 views

Parsing time ranges with PyParsing

The following code is intended to parse a string of the following format and return whether the current time falls in that window: ...
4
votes
1answer
75 views

Method to return a string of max length (in bytes vs. characters)

In my (c#) code, I need to generate a string (from a longer string) which when UTF-8 encoded, is no longer than a given max length (in bytes). ...
5
votes
0answers
91 views

String matching algorithm

I have been going through algorithms and data structures and recently came across string matching algorithms. I have not yet wrapped my head around the significance KMP algorithm so I came up with ...
5
votes
1answer
54 views

Bi-directional atoi()

I am implementing atoi() by traversing a string from the beginning as well as from the end. Is there anything I can improve? ...
4
votes
1answer
60 views

Permutations program in Python

This code asks for letters and a number of letters per word and generates all possible permutations. Then compares those permutations with an English dictionary and creates a list with all the words ...
0
votes
2answers
38 views
3
votes
6answers
531 views

Code Hunter 2.06: Count occurrences of 'a' in a string

I'm playing Code Hunt on level 2.06 (loops). This level is about counting the number of "a" in a String. ...
2
votes
1answer
43 views

More Pythonic version of finding substring with one glob-like expression

Giving the following example list the task is: find out whether the second expression is in the first one. * shall be considered as a wildcard for any ...
10
votes
1answer
104 views

Swift string multiplication

I like Ruby's string multiplication so I thought I'd see if I could do it in Swift. I came up with these implementations: ...
9
votes
4answers
654 views

Determine if one string occurs at the end of another

Exercise 5-4 Write the function strend(s,t), which returns one if the string t occurs at the end of the string ...
2
votes
2answers
86 views

Defining a zip code string

I'm following this ...
5
votes
2answers
68 views

Convert string to multiline text

I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
4
votes
1answer
20 views

Converting the integers to their equivalent string representations

I have the following function which converts an integer (such as 103 to its string representation "one hundred three"): ...
1
vote
2answers
60 views

Given suffix array and a pattern, search if given pattern exists

Given a suffix array for a word, check if a pattern (consecutive chars) exists. Example: A suffix array constructed for "ameya" should return true for "ame" but false for "foo" or false ...
5
votes
4answers
162 views

Faster method to find data using search word?

I need to search through a string array to find every occurrence of "Parameters Table", and between each "Parameters Table" and the next, get another string from a specified index (that remains ...
2
votes
2answers
67 views
4
votes
3answers
69 views

String self-similarity

It's a string problem I have been making on Hackerrank. It is executing fine on all test cases except the last two. These last two test case are declaring it "Terminated due to time out". C programs ...
2
votes
2answers
58 views

String sanitisation function

I have a search function on my website. In addition, elsewhere I have a place where users can submit categories for their posts. I want the categories to have an uppercase first letter and the rest ...
4
votes
2answers
262 views

Manipulating filenames using Python

I was tasked with creating a script to be able to rename some files and then move them into different folders based on a code in the filename. ...
6
votes
1answer
164 views

Converting any PHP function toString() like in JS

In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string. I'm working on a ...
6
votes
1answer
70 views

Text Analysis web page

For a homework assignment, I made a web page that has a text area. The user inputs some text, hits the analyse button, and the output is supposed to be a list of the frequency of words of a given ...
3
votes
2answers
80 views

Word counter script

I made a word counter. It works as long as there aren't any lone punctuation marks. How could it be improved? (Could it be made simpler? Are the comments detailed/clear enough? etc.) I know it's ...
2
votes
2answers
129 views

Check Abecedarian word

An 'abecedarian' is a word whose letters appear in alphabetical order. Write a program which will determine whether the given word is abecedarian or not and print ...
2
votes
1answer
32 views

Optimizing string replacement program that uses recursion

I have the following string replacement program for a string of size 256: I am replacing the string "\'" with the string ' Please suggest any modifications if needed or any ...
3
votes
1answer
91 views

Converting from std::wstring to std::string in Linux

I was bothered by inability of C++ to mix cout and wcout in the same program - so I've found this question: Converting between ...
2
votes
1answer
75 views

Easiest way to remove extra spaces from user input?

What I want to do: Take user input strings and add them together with proper spacing. HTML: ...
3
votes
1answer
69 views

Breaking after one of several string replaces occur

I have a script that matches a string against ~20 different regexs for the purpose of changing it. They are ordered and formed that the string will only ever match against one. How can I avoid ...
6
votes
2answers
142 views

Z-Algorithm for pattern matching in strings

I was trying to refactor the following Python code (keeping the same time-complexity) which is an implementation of Z-Algorithm for pattern matching in strings. ...
4
votes
1answer
98 views

Convert hex string to byte array

The goal is to convert a hex string to a byte array with the following requirements: \$O(1)\$ additional space apart from input and output. \$O(n)\$ runtime This mostly just prohibits creating a ...