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.
2
votes
0answers
39 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
38 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 ...
11
votes
2answers
436 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
121 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
27 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
821 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
28 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
30 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 ...
12
votes
1answer
422 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
42 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
54 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
209 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
45 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:
...
2
votes
4answers
142 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 ...
2
votes
3answers
83 views
Counting the UpperCase, LowerCase, Numbers and Special Characters in a String
I'm making a Java program that will analyze the given String by counting the lowercase, uppercase, numbers and special characters. Is there a way by making it functional?
...
1
vote
2answers
42 views
Regex to Match Email address
I have the below regex to match email address with atleast one @ and one .
...
3
votes
3answers
70 views
14
votes
2answers
834 views
The Breakfast Club attendance
This code checks a string called breakfastHours similar to
1567
which translates to Monday, Friday, Saturday, Sunday.
...
6
votes
1answer
608 views
Implementing a C++11 raw string class
I'm trying to implement a RawString class that conforms to C++11:
...
2
votes
2answers
53 views
Ordering Gallery images by custom order
I wrote some code a few weeks ago, to take a string similar to
seq[]=8&seq[]=7&seq[]=5&seq[]=1&seq[]=4&seq[]=3&seq[]=6&seq[]=0&seq[]=2
and put it into a gallery, ...
-1
votes
0answers
13 views
scanf() works despite 0-length buffer and compiler warning. What is going on? [migrated]
My compiler (clang) shows this message:
...
1
vote
1answer
29 views
Print all subsets and permutations of a string
The following code is designed to accept a string from the user that is at most 5 characters long. It will then find each possible substring of the string and print all possible permutations of each ...
4
votes
3answers
141 views
Extracting numbers before colon
I need to extract all numbers before a colon in a string, e.g.:
abc1234:blah -> 1234
5n63:124 -> 63
stringwithnocolon -> ""
stringwith:nonumber -> ""
Limitations:
no external dependency (looking ...
4
votes
4answers
165 views
Truncate String to target length using only whole words
I've got a bit of code that I'm wanting to tidy up. The aim is to take a String that consists of multiple words connected by a separator (It's produced using ...
5
votes
2answers
99 views
Get line from string function
I have asked a previous question but at the last moment I realized that the code does not work as intended as it has some small bugs.
I got some ideas for improvement though, but they didn't seem to ...
-2
votes
2answers
48 views
1
vote
1answer
64 views
Determining the existence of string Intersections
Problem:
Given 2 strings, consider all the substrings within them
of length len. Len will be 1 or more.
Returns true if there are any such substrings which appear in both strings.
Compute ...
3
votes
1answer
74 views
Finding the length of the largest run
Note: A run is a series of adjacent chars that are the same.
I just want to answer a few questions:
Is this readable?
Does it need commenting or is it self-descriptive enough?
Are there any ...
6
votes
0answers
67 views
Name Filtering using a Trie
This question suggests a different (improved?) implementation for searching/filtering names based on a search query. This is based on the question here: Name filtering in Java
A Trie allows the ...
5
votes
2answers
92 views
Find if a word with wildcard exists in dictionary [closed]
This is a question from a phone interview I had.
The question was in 2 parts:
a. find("cat") -> T/F suggest a data structure to find is if a word
exists in a large dictionary, how will one node ...
6
votes
2answers
82 views
Name filtering in Java
I have a search box for searching for people in a list of names.
Here is the code that runs every time the query changes. I could not find anything open-sourced for this, so I wanted to make sure ...
4
votes
2answers
149 views
Map String to list of string
Input: String : Title; List Tags
Problem statement:
Need to map title to tags, e.g. title is "china man japan beijing bell" and tags are ...
4
votes
1answer
54 views
Sentence formatting
I wrote this function to format a given sentence via Java, and I'm wondering if there is a better way of doing this without use of external libraries, such as with regex.
...
3
votes
2answers
50 views
split-string for R7RS
A split-string function seems to be missing in R7RS.
I came up with the following implementation today:
...
1
vote
2answers
160 views
String 'expanding' - reinserting repeating characters
The challenge: Given a String, for each digit in that original string, replace that digit with that many occurrences of the character following it. So a3tx2z yields ...
6
votes
3answers
160 views
Checking for balanced parentheses
I wrote a method to check if each parenthesis in a string is closed. It should take into account the order in which a parenthesis is presented, e.g. "hello)goodbye(" should return false even though ...
10
votes
4answers
128 views
Morse Code String
I was bored recently and decided to write a class, MorseString. What this class does, is it takes a String that is coded like ...
4
votes
4answers
108 views
10
votes
3answers
354 views
Mutable String Class
Here is a String class that I've made for fun in my spare time, for myself.
I have a few concerns about it, and am considering going immutable or a mix of the two ...
4
votes
2answers
83 views
Constructing a long string
I have a task to construct a long properly formatted string in Java. This string will be then used as a header of the logfile that we write during the program execution. As the program runs on server ...
4
votes
1answer
44 views
String parsing/stripping code
I am mostly interested in how the parse_string function could be improved. But any comments on my test strategy also welcome.
The input is a string which can be ...
14
votes
2answers
101 views
Playing with strings
I wanted to dust off my C skills, so I decided to write a couple string manipulation functions.
I aimed for simplicity and safety. Performance was not a concern.
Please be a thorough as you like. C ...
8
votes
3answers
122 views
Implementing StrStr()
This is a naive implementation - I know that there are algorithms like KMP
However I was trying to implement it as best as I can.
...
3
votes
4answers
146 views
Implementing Substring in C#
I was trying just as a practice to implement substring on my own.
the Test is inside the Ctor just because it is easy.
...
-5
votes
1answer
50 views
What are the Steps/Algorithm to load/Parse an XML File? [closed]
I want to write an xml parser by my own, i know to search for a string, load files into memory using vectors, but is theres a way i can use this to load and parse xml file, i were told to make a DOM ...
1
vote
2answers
73 views
Implement StringBuilder
I was asked this in an interview yesterday. I could add whatever methods, members and constructors I wanted but I couldn't change the signature of the provided ...
4
votes
5answers
749 views
String vs List to check if a country is part of a continent
I simply need to check if a country is part of a particular continent (only one). The continent has around 50 countries. The list is constant and must be initialized at the time of creation. Which one ...
3
votes
1answer
69 views
Parsing Lua 5.2 strings with patterns
I wrote some code to parse Lua 5.2 strings in Lua 5.1, using patterns. It's a bit too slow, but it works fine as far as I tested.
...
2
votes
1answer
16 views
Custom moment formats based on string length
Just wanted to gage how solid this code is. With moment cracking down on lazy formatting I thought this was a good way to parse the string for what format to use.
...
4
votes
3answers
236 views
Length of the longest sequence of repeating characters
I have been going through some CodingBat exercises and I came across this problem. "Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are ...