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)

2
votes
1answer
19 views

Changing the prototype of the String object

Are there any pitfalls in changing the prototype of the String object? I'd like to change the word substr to "left": ...
1
vote
2answers
40 views

“The Love Letter Mystery” - storing and comparison of strings

The problem goes like this. Change the strings provided by user to form palindromes. To do this, 2 rules are: (a) Reduce the value of a letter, e.g. Change 'd' to 'c', but cannot change ...
4
votes
3answers
58 views

Finding strings inside of other strings in order in C

A question on Stack Overflow recently intrigued me to the point of me implementing the functionality in C. Can you critique this algorithm and tell me what is good and bad about it? This program will ...
8
votes
2answers
63 views

Optimizing String combinations in Java

I need to obtain all combinations of a String of length k from the given elements. For example, for ...
5
votes
1answer
159 views

Logging with date in Java

I write my log messages in JTextArea. Each message should have a time added. I created a following method: ...
6
votes
4answers
731 views

String case reverse function in C++

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Let's get critical here. ...
4
votes
3answers
94 views

String case reverse function in C

This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Besides documentation, in particular, any thoughts on the type ...
4
votes
4answers
38 views

Trimming fgets(): strlen() or strtok()

After a successful fgets(buffer, ...), it is often desirable to trim a potential End-of-Line \n. Of the following 2 methods, ...
12
votes
6answers
510 views

Check for balanced parentheses

I was given an assignment to check for balanced parentheses from an arbitrary string where parentheses are defined as (, [ or { and their respective "closing" ...
9
votes
2answers
126 views

StringBuilder in VBA

In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To ...
2
votes
2answers
54 views

Splitting a Multi-FASTA file into individual files

I have written a program to split a Multi-FASTA file into individual fasta files. ...
3
votes
2answers
150 views

Generating character permutations

I want to generate a 'dictionary' containing all 8 character permutations of upper-case letters such that the output file looks like: ...
7
votes
3answers
510 views

Concatenate two strings

I am learning C and wrote a function to concatenate two strings in C. Please let help me improve it. ...
2
votes
4answers
270 views

Parsing a string to get the values of certain attributes

I have written a small method that extracts certain information from a string. An example of such a string is ...
11
votes
4answers
172 views
+50

Fastest way of removing a substring from a string

Taking a break from my C++ series, I recently reviewed the code in this question. I ended up writing my own separate derivation of the function so that I could remove all of the substrings from a ...
6
votes
5answers
573 views

Given a String, return a boolean if it is a number

Yesterday in an online interview, the interviewer asked me this question: If I give you a string, you have to return if a string is number or not. You are not allowed to use any parse function ...
6
votes
2answers
179 views

Trim a string to a given start and end

Are there any other more exotic ways ... or is this one just good? ...
1
vote
2answers
63 views

Reverse Message Program

...
3
votes
1answer
89 views

Example String Class in C

I wrote this small example piece of OOP being implemented in pure C. I wanted it to be reviewed for the following points: Portability Performance And especially Usability "How does it look" ...
5
votes
4answers
527 views

Arranging words in sentences alphabetically

For an online contest whose problem is here, I wrote some code. In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the ...
3
votes
2answers
90 views

Longest Common Subsequence and Longest Subsequence Palindrome

The following code computes: The longest common subsequence between two strings, where a subsequence of a sequence does not have to consist of contiguous elements of the sequence. The longest ...
0
votes
0answers
38 views

Longest increasing subsequence and common substring

I wrote a program that computes longest increasing subsequences and common substrings. Can you please suggest more elegant and eloquent ways for this program? (Perhaps better ways to represent a ...
3
votes
1answer
95 views

Finding the longest unique sub-string in a string

I recently interviewed with a company for software engineering position. I was asked the question of finding the longest unique sub-string in a string. My algorithms was as follows: Start from the ...
0
votes
1answer
45 views

Converting integers to strings

I drafted a method that I intend to use to convert integers to strings. Is there a way to make it faster? Are there any "simple" changes I could make to improve its performance? This cannot be done ...
1
vote
2answers
92 views

Most common words in a text file

I've made a program that outputs you the most common word in txt file. Does anybody know how to optimize it so that it would work for bigger files and run faster? ...
2
votes
2answers
102 views

Evaluation of a solution for Run-length encoding algorithm

I wrote an answer for the following question and wondering if there is any better approach to it. Using the Java language, have the function RunLength(str) take ...
8
votes
4answers
775 views

Pig Latin in Java

I've done my second application in Java now. I want to know if: This code is efficient This code can be written in a shorter and faster way Any flaws Any misuse or better use of concepts Main ...
1
vote
1answer
200 views

Reversing a String in Java

I'm new to Java and I want to know if this code is efficient, and if there a shorter and faster way to reverse a string. ...
8
votes
3answers
129 views

Basic string compression counting repeated characters

My task was to implement a method which performs basic string compression by counting sequences of repeating characters. Given "aaabbbccc" it should return ...
5
votes
3answers
65 views

Windows forms set saved groupbox location settings

I have a Windows form that when a user moves some groupboxes around, before the application exits, it saves those X and Y coordinates into a MySQL database (with a bit of added text to identify which ...
4
votes
3answers
165 views

Prefix and suffix detection algorithm

I have written an algorithm intended to find prefixes and suffixes in arrays of strings. I would like to get opinions/suggestions/reviews on the code I wrote (specially cases in which my code would ...
11
votes
5answers
869 views

Finding longest word in a string

I was working on a problem from Coderbyte. The challenge was to write a function that takes in a string and returns the longest word in the string. If two words are the same size then it asks to ...
3
votes
1answer
186 views

Removing whitespaces in a string

I wrote this function to remove whitespaces in strings. Please help me improve it. I intended to use the function for a Big Integer ADT. ...
4
votes
1answer
179 views

Find repeated substrings of length 3 in a string

The following method receives a string and finds all occurrences of repeated substrings with a length of three characters, including spaces. Is this a good approach? ...
0
votes
1answer
55 views

Reading/writing null-terminated strings from socket

I need to handle C style ('\0' delimited) strings from/to a socket and came up with this as a first attempt: ...
7
votes
3answers
1k views

Replace each whitespace in a string with “%20”

My implementation: ...
6
votes
3answers
590 views

String compression implementation in C#

I wrote a method that reduces a string like aabcccccaaa to a2b1c5a3 My implementation: ...
3
votes
2answers
96 views

Implementing faster StringBuilder that only works with ASCII strings

I wrote a StringBuilder that works only with ASCII strings. the current append performance is almost identical to BCL StringBuilder append performance. I want some tips on how to make it faster, and ...
3
votes
2answers
97 views

Writing strings to a file

This opens a file and writes 5120 times a string to it, and if the file doesn't exist it creates a new file. The name of the file and the string are chosen randomly. I would like to know if there is a ...
2
votes
2answers
97 views

Determining the number of vowels in each word from a file

I'm 5 weeks into my first C++ class. I'm curious about how this code could be improved, more streamlined or simply things that I could/should have done better. The project was: Read from a .txt ...
4
votes
1answer
59 views

Regular expressions - match only specified string length

I'm learning regex. Here I'm checking a string of type aA1 but want also to check it is only 3 characters long. Is there a better way of doing it please? ...
8
votes
4answers
127 views

Align Strings for Output

I wrote a class which can format input so that it is properly aligned. I'm interested in all suggestions (regarding structure, usability, style, naming, comments, etc). I'm especially wondering ...
4
votes
2answers
77 views

String representation of Tree

I have a Tree class, defined as follows: ...
9
votes
6answers
2k views

Reversing a String using Stack

Is this code okay? ...
5
votes
2answers
214 views

Re-arrange a string into a { consonant, vowel, consonant, vowel … } sequence

I was prompted to give someone advice about the following problem: Given a string with equal amount of vowels and consonants, re-arrange it so that it follows the sequence { consonant, vowel, ...
3
votes
3answers
82 views

Multi-replacement in a string, independently and prioritized

I need a shorter way to do this. input: an ordered list of string pairs L; and a string s task: for each pair ...
3
votes
1answer
74 views

Count frequency of words in a string returning list of unique words sorted by frequency in descending order

I have the following solution but I am trying to optimize it to run in O(n) time, any thoughts? I first split the string removing any non-alphanumeric characters, then split the words using spaces ...
1
vote
1answer
32 views

Using Regexp to select the date from a string [closed]

I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is ...
9
votes
3answers
121 views

Ugly workaround to get the vbext_ProcKind of a procedure is breaking encapsulation

This is a follow up to Extending the VBAExtensibility Library. It turns out that code had a really nasty bug. Anytime vbeProcedure.StartLine got called, I was ...
6
votes
3answers
560 views

Comparison between strings

This review is very short and very straight-forward. There are two people in the team and the checked-in code looks as follows. ...