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
1answer
30 views

Create Java object from from page content or plain text

My job is to make a specified java objects from web page that contains following text: Companies: ...
-2
votes
2answers
50 views
4
votes
2answers
226 views

Longest substring with unique characters

Find the length of the longest substring without repeating characters Any comments on my code? ...
4
votes
3answers
982 views

C++ Pig Latin program

I'm just wanting some input on to how others would approach this problem. I am learning and wish to gain insight on others techniques. Be as critical as you need. I want to learn. I feel this code is ...
6
votes
1answer
88 views

Simple syntax highlighter in Javascript - SQL highlighting

Yesterday and today I've made a very basic syntax highlight. It creates a function in the window object that handles part of the job: ...
6
votes
2answers
278 views

Next revision letter

This is a fun one! I wrote some code to automatically get the next revision letter for a file by looking at the existing letter. It works, but I think there is room for improvement as far as ...
1
vote
1answer
33 views

Taking advantage of the falsey and ineffective “” empty string

The following code snippets are academic. I was required to make a PHP generated HTML interface for a MySQL database of a movie rental store, and the requirement was filtering the displayed movies by ...
2
votes
1answer
78 views

Count balanced substring

Chandan got bored playing with the arrays all the time. Therefore he has decided to buy a string \$S\$ consists of \$N\$ lower case letters. Once he purchased the string, He starts formulating his own ...
3
votes
2answers
67 views

Extracting a sentence containing a specific word from a longer text

My goal is to return a specific sentence in a story that contains a given word. Returns null if the word is not in the story. I'm ok with returning the first ...
1
vote
2answers
41 views

Neatly printing integers interspersed with spaces - follow-up

See the previous iteration. At this point, I have "digit group" length assumed to be always 3 the user can pass the delimiter character of his/her own handles (seems to handle) the minus sign ...
1
vote
1answer
18 views

Neatly printing integers interspersed with spaces

The next iteration is here. I have this small method for printing long integers neatly. For example: ...
5
votes
4answers
311 views

Word Guessing Game

I'm trying to learn Java (albeit rather slowly). I'm in a computer science class at my highschool and I've written this little bit of code for a project. Basically it is a word guessing game where if ...
6
votes
3answers
165 views

Expanding a string to a certain length

I wrote a function for repeating a string to a certain length. For example: ExpandString("Test", 11); // output: "TestTestTes" Are there any optimizations ...
3
votes
2answers
54 views

Phone keypad implementation

I was wondering, beyond the standard improvements that this needs, is there a more "clever" way of solving this problem? The problem is to translate letters into digits without changing the format of ...
4
votes
1answer
56 views

Boolean expressions from infix to postfix notation using Dijkstra's Shunting Yard algorithm

I began working on a Java library that receives a boolean expression such as not A and (B or not C), compiles it to a circuit of logical gates \$\mathcal{C}\$, ...
3
votes
1answer
38 views

Create a list of all strings within hamming distance of a reference string with a given alphabet

For a bioinformatic problem, I found myself wanting to create a list of strings within Hamming distance "k" of a reference sequence. I wanted to do so quickly and pythonically. I've implemented it in ...
7
votes
1answer
690 views

A little integer parser vs clean code

I was said to post this as a new question. I improved my code from: Little part of the string to integer parser vs Clean Code However I think that it break SRP as it parses, iterates through string ...
3
votes
2answers
40 views

String trim functions with destination size limitation

3 string trimming functions: Trim whitespace from the beginning of a string. Trim whitespace from the end of a string. Trim whitespace from both ends of a string. Looking to improve code ...
4
votes
4answers
145 views

Little part of the string to integer parser vs Clean Code

I started reading a Clean Code book and some other articles on the Internet about OOD and design patterns and I'm a little confused. I've started to code a little string to integer parser which ...
4
votes
3answers
83 views

Console app to compare all directory names for similarity

I just got the urge to write a small console app to compare all directories name for similarity. I have > 3000 directories and over time some of them are really similar, eg. an update: Test Case ver 1 ...
5
votes
2answers
84 views

Getting a substring of a delimited string

I have some underscore-delimited strings like abc_def_ghi. I would like to get a substring out of the string made of one or more delimited substrings, so that if I ...
1
vote
3answers
65 views

Checking whether two strings are isomorphic

I was trying to solve a problem to determine if 2 strings are isomorphic. They are isomorphic when each character in string one can be replaced with another character in string 2. Two different ...
-2
votes
1answer
35 views

Text-to-Morse Code translator [closed]

I'm curious if anyone can come up with a better code structure (loops, checks) than what I have done. I need to change the structure because my teacher was unhappy with the for loop and if else's for ...
2
votes
3answers
49 views

Join 5 optional strings with a joiner character

I need to append some query parameters to my API URL. The consumer of my API would pass me this optional structure called as APIParameters, which contain 5 optionals, one array of strings and rest ...
10
votes
1answer
131 views

Injecting the Maharajah into the Barbarous Child's introduction

I'm building a random text generator! My idea was to borrow slightly from the string.Format method styling, have a "format string" that controlled the overall ...
8
votes
2answers
93 views

ASCII graphic waveform generator

Working on some documentation lately, I had a need to convert a number of asynchronous serial waveforms into ASCII graphics characters. Rather than draw them by hand, I decided to write a program to ...
15
votes
3answers
2k views

Finding anagrams - Empires strike back

Recently as part of a job interview I was given the following coding task: Attached is a gzipped text file of about 100,000 English words. Write a Python, C or C++ program that finds all the ...
5
votes
1answer
47 views

Generating a topographic string

I am working my way through some exercises, using Java, to learn about programming. I have just finished the following Code Golf challenge: Here is some example input, so I can explain what the ...
0
votes
0answers
43 views

Select type stringification for ostream output using C++11 template mess

The objective is to select which function is used to represent a type as a string for output on ostreams. The code here allows to explicitly choose a function, or to fallback on a java style ...
1
vote
0answers
96 views

Word separator and Pig Latin program - final edit

This is an updated version of my previous Java program that asks the user for a sentence and then separates the words and then converts the sentence into Pig Latin. My previous program was working, ...
5
votes
3answers
217 views

Using recursion to count substrings (with exceptions to the rule) in Java

I am going through the CodingBat exercises for Java. Here is the one I have just finished: Given a string, compute recursively the number of times lowercase hi ...
7
votes
1answer
103 views

Equation parser and solver

I wrote this equation parser and solver, I feel like it is well documented and tested: ...
4
votes
1answer
70 views

Finding common elements, ignoring duplicates, in two given string arrays

I am going through the CodingBat exercises for Java. Here is the one I have just completed: Start with two arrays of strings, a and ...
2
votes
1answer
59 views

Replacing all occurrences of a substring in a string without using regex

Problem Statement: Given two strings, base and remove, return a version of the base string where all instances of the remove string have been removed (not case sensitive). You may assume that ...
2
votes
3answers
84 views

Parsing a single CSV line into a list of strings

I've written this method to replace an older method that was much simpler, but used the regex split method and couldn't tell if a comma was in quotes/brackets/etc. and didn't read double quotes as ...
3
votes
1answer
45 views

Word ladder solution in Java using matrix

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that only one letter can be changed at a time and each intermediate ...
1
vote
1answer
24 views

Splitting a string basing myself on categories

I was thinking about splitting a string based on certain categories, for example alphabetic and numerical, lower and upper case, and even the 3 lines of the keyboard. I wrote a generic function for ...
5
votes
1answer
66 views

Prefix- and z-functions in C++ (string algorithms)

Let us define prefix-function(string)[i] as the length of the largest prefix of string, which is also a suffix of ...
3
votes
2answers
95 views

Suffix array construction in \$ O(n \log^2 n) \$

Here is my implementation of the suffix array construction algorithm which follows this paper (specifically, pages 4 and 6). ...
0
votes
1answer
30 views

Word Counting from Array onto Output File [closed]

For this problem, I have to have two text files: one for list of words that need to be found and other containing the document that needs to be search. The results would placed in a output "results" ...
4
votes
2answers
135 views

Split string by substring without using String.Split()

The Aim Since I very rarely write code to do things other than business logic anymore I've set myself a challenge: Split a string into a list of substrings by splitting on a matching string, without ...
3
votes
4answers
552 views

Validating Firstname and Lastname

I have written some code in Java that checks if the strings Firstname and Lastname are valid names. These are inputted by the ...
12
votes
2answers
408 views

Split string in half and change case accordingly

I found the following challenge online: Create a function that takes a string and returns that string with the first half lowercased and the last half uppercased. eg: ...
3
votes
3answers
227 views

More portable toLower() implementation

I am challenging myself to try to attempt to write a function that is as efficient, portable and failsafe as possible. The function is very simple and just converts a ...
6
votes
4answers
417 views

Summing digits of an alphanumeric string

I am going through the Java CodingBat exercises. Here is the one I have just completed: Given a string, return the sum of the digits 0-9 that appear in the ...
4
votes
3answers
64 views

Case insensitively removing a substring, efficiently

I am going through the CodingBat exercises for Java. I have just completed this one: Given two strings, base and remove, ...
2
votes
1answer
42 views

Repeated string concatenation

I've been looking for a way to have a predicate that establishes that all elements of a list are substrings delimited by a given string. Analogues in other languages include: ...
-2
votes
2answers
29 views

Extracting first initial and last name [closed]

How can I do this better? $a = "Tom Smith" ; $e = $a.substring(0,1) $ee = ($a).split(" "); $y = $e + $ee[1]; $y TSmith
1
vote
4answers
99 views

Redacting everything in a string except a particular word

I am working through the Coding Bat exercises for Java. Here is one I have just completed: Given a string and a non-empty word string, return a version of the original String where all chars have ...
6
votes
2answers
208 views

Removing Asterisks and neighbors from a string

I am going through the CodingBat exercises for Java. I got to this problem: Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its ...