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)

3
votes
4answers
94 views

Extremely simple character manipulation

Given a string, this code Multiplies odd numbers Subtracts even numbers, do nothing if only one even number is found Turns uppercase letters to lowercase and vice versa I think this code is too ...
2
votes
4answers
62 views

Palindromes with stacks

I'm creating a simple function to verify whether or not a string is a palindrome, and must use stacks in solving it. ...
4
votes
2answers
87 views

Function to get top k words in a given String

This is a two-part job: to identify a word to find the top k words I've tried to use regex to split but it's taking 10x more time when string is really long. ...
3
votes
2answers
43 views

Transform a string into an array based on grouping rules

I've got a simple spec for defining character sets, ranges, or wildcards. I'd like to take the string and appropriately create an array based on these rules. I have a solution but I'm sure there is a ...
2
votes
1answer
112 views

Reversing the lines of file

I have written a program to reverse the lines of a file. I made use of the String [] approach with the String.split(separator) ...
1
vote
5answers
44 views

CCC Rövarspråket (Pig Latin) translator

I have a challenge: In Sweden, there is a simple child's game similar to Pig Latin called Rövarspråket (Robbers Language). In the CCC version of Rövarspråket, every consonant is replaced by ...
10
votes
3answers
185 views

Empty Line delimiter, single line output

I'm used to only processing, at most, one line of a file at a time. This is my first time changing the delimiter, and the objective here is to take a file containing lines such as: ...
1
vote
0answers
19 views

Efficient Strip Special Characters

I have a private function in PHP that takes a given URL string and just leave the Alpha or numeric and certain punctuation left. I need the stripping of string due to having it match against ...
6
votes
2answers
85 views

Grouping An Array of Strings into Anagrams

Ok, so this code works perfectly, however, I've not coded in Java for a long time, so I'm worried about breaking Java conventions, but even more important, I would appreciate any comments on making ...
3
votes
2answers
87 views

Log-reading & String-matching with hashtable for fastest execution speed

I'm currently enjoying this exercise I'm working on for fun: I wish to write optimized code for the searching of particular strings per line in a (very large) file, counting how many exist, and ...
2
votes
1answer
35 views

Date-filtering function

Please check if this date filtering function is inefficient code. It seems so to me, but I can't figure out the other way around it. ...
4
votes
1answer
27 views

K&R Exercise 1-20: tabs to spaces

I'm learning C with K&R 2nd Ed. I've just completed the exercise 1-20 and I would know if my code is correct (i.e. answering the question) and if my style is not too bad. Or just some feebacks to ...
7
votes
2answers
230 views

Identifying which paragraph, if any, is a superset of all words in a document

Description need to find out the paragraph number which is containing all the words in the file. input file java.txt What is a JVM? What is the most ...
6
votes
2answers
122 views

Splitting three comma-delimited strings

I've been reading about loops this morning, to try to improve this snippet of code: ...
2
votes
2answers
231 views

Text tokenizer - extract words and positions from text

I have Set of character delimiters (DELIMITERS), eg . ...
3
votes
2answers
49 views

Titleize words in a sentence but with some conditions

Below is the code I have written to capitalize all the words of a sentence except if The words belong to the littleWords list. The word would be capitalized if it's the first word of the sentence ...
2
votes
2answers
123 views

Vowels in a string, patterns

Checking if all five vowels are present in a string. ...
4
votes
5answers
118 views

Optimising single-delimiter string tokenisation

I am trying to optimise my tokenizing of tab delimited strings: ...
0
votes
1answer
36 views

Permutations of a string

I wrote the following code to permute the characters of a string assuming there is no repeated character. I also want to make sure the space complexity of this algorithm is \$O(n*n!)\$: There are ...
0
votes
1answer
31 views

Natural sorting/comparing algorithm in TypeScript

This code sorts string that may contain numbers in natural order, that's it, "item 2" comes before than "item 10". It currently ignores case. I plan to implement options to handle case sensitivity and ...
1
vote
2answers
24 views

String appending function (location-independent)

Very useful operation that hasn't been merged into a function.. until now. This is supposed to insert a substring into a previously d.allocated source string. ...
1
vote
2answers
34 views

Work out if a string is “fieldname” or “tablename.fieldname”, and assign variables

Is there a neater way to write this code? ...
3
votes
3answers
163 views

Count chars, words and lines

Any suggestions are welcome. ...
3
votes
2answers
62 views

Counting the proportion of vowels in substrings

I'm looking for an algorithm to make my code faster and better for big strings. Problem link Let the simple prettiness of a string be the count of vowels (I, E, A, O, U, Y) divided by the length of ...
6
votes
2answers
55 views

Basic String class

I wanted to create a basic String class that will hold a CString and have: constructor, destructor, copy constructor ...
1
vote
1answer
30 views

Read file directly - simplified

In order to read a whole file as a string using standard libraries you have to allocate memory, terminate the string, determine size of the file and size of each element. This could happen with ...
6
votes
1answer
82 views

A super string cleaner

I need a method that clean up a string considering these few rules: Remove or not Spaces Remove or not Special Chars Remove or not Numbers Descaptalize or not the string (this is don't really needed ...
2
votes
2answers
166 views

Get alpha numeric count from a string

Following is the code I am using to find a separate count for alphabets and numeric characters in a given alphanumeric string: ...
1
vote
2answers
44 views

Checking consecutive characters in a string

First of all, this code will ask for a number (first) on how many test the user would like to have. Then the user will input the strings depending on how the number entered. ...
5
votes
4answers
58 views

C readline function

I wrote this function for my next learning project (cfg parser). What do you think about it? ...
3
votes
1answer
46 views

Representing Objects as strings in VBA

I am working an a more meaningful way to print objects in VBA. The desired result should look something like this. ...
10
votes
3answers
492 views

Usage of StringBuilder for returning copies of a string

Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front: ...
6
votes
4answers
209 views

Readline function

I have developed a readline function in C and I want to know your opinion on it: ...
4
votes
1answer
53 views

Multiplying Lists

Challenge: Given 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists Specifications: Your program should accept as its first argument a ...
1
vote
1answer
33 views

Cutting substrings in Haskell

How can I improve readability of this code? indentChar needs to be reused elsewhere. ...
0
votes
4answers
48 views

Remove extra spaces from a string without using Regex or any internal library methods

The objective is to remove extra spaces from the below string: " Today it is going to rain. " so it looks like below ...
2
votes
0answers
64 views

Function to split a given string according to predefined patterns

Just started to use PostgreSQL and want to be sure that I'm not making any mistakes. Here's a function that splits given string according to predefined patterns. It's part of a trigger function used ...
1
vote
0answers
46 views

Matching file names to an array of product SKUs

The Challenges: There are many SKUs, (around 50,000) which I'm trying to match to around the same number of image files. SKUs contain characters that are not legal in filenames, which must be ...
12
votes
2answers
504 views

Reverse a sentence quickly without pointers

I am trying to reverse a sentence contained in a string and return a string in the quickest way possible using the least amount of memory. Also I don't want to use any unsafe code, so no pointers are ...
3
votes
2answers
144 views

Uppercase the initial char of every string in a list

My problem is that I have a sequence, potentially infinite, of strings. Let's suppose it to be {"Mickey Mouse", "Bugs Bunny", "Winnie the Pooh"} I have to make ...
4
votes
1answer
40 views

String manipulations (reverse a string by characters, permutation)

I'm trying to solve simple Java problems in various ways. Could anyone comment about the code, like how it could be better, and what could be a problem? ...
8
votes
5answers
861 views

Assembling a user agent descriptor, implemented using StringBuilder vs String

I think performance won't be a big issue here as the concatenation only happens once (2-3 at worse because of multiple threads). Out of the two methods, which one would you prefer, in terms of ...
1
vote
1answer
33 views

Memory searcher function test

This is part of the project I started just now. It is a function that returns the offset address of a first occurrence of a string match into a given range of memory blocks. ...
-2
votes
1answer
44 views

Clojure koans 14 - converting a map to a string

The koan is at the end of this snippet. It requires you to write a function to convert a map to a string, and then prepend a full name to it. The following solution works fine. I am just wondering if ...
13
votes
1answer
487 views

Capitalize the first character of all words (even when following a '-')

I got it working, all variations are displayed Sint-Anna as should be, but I wonder, is there a simpler way to this, since it looks very cluttered? ...
3
votes
2answers
51 views

Python path-breaking script for use in R

R does not support line continuation as Python, and it's disturbing to have long file paths like /media/user/data/something-not-very-important-but-super-long/some-curious-secret-file.pdf and ...
3
votes
1answer
90 views

Finding the shortest substring containing keywords

Problem: Write a function that takes a String document and a String[] keywords and returns the smallest substring of ...
5
votes
2answers
238 views

C# approach to prevent null references in strings

My insight here is that it's usually not useful to distinguish between null and empty strings. Sometimes it is, but usually not. Usually I like to assign my strings ...
3
votes
1answer
50 views

All balanced parentheses for a given N

Write a function (in Haskell) which makes a list of strings representing all of the ways you can balance N pairs of parentheses: Example: ...
3
votes
4answers
187 views

Java vs C++ (JAVAC)

Here's the problem for Java vs C++ (JAVAC): Java and C++ use different naming conventions: In Java a multiword identifier is constructed in the following manner: The first word is written ...