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.
4
votes
4answers
164 views
Validating a tab-delimited string
This code checks if string has correct format for passing to struct. Correct format needs to be [123456789'\t'First Name'\t'Last Name'\t'City]. I didn't know how to ...
1
vote
1answer
44 views
8
votes
4answers
2k views
Randomly generate spelling mistake in string
My code will generate a spelling mistake inside of a string 50% of the time.
It will retrieve a letter from a random index in the string like, "t" and then duplicate that letter like, "tt" and store ...
1
vote
0answers
16 views
alternatives solutions to the problem of trying to find a substring within a string using Regular Expression
I'm new to Java and is trying to find a substring within a string using Regular Expression . Below is the code I have came up with. However, I was just wondering if there are any alternative ways to ...
3
votes
2answers
80 views
Simple function to generate a list of letters
I would like get some suggestions for improvement of this function, and alert me about any dodgy practices that you find.
I have been trying to learn python for a short time now and I would like to ...
3
votes
1answer
26 views
1
vote
1answer
43 views
Creating a RegExp in JavaScript from user input
My goal is to accept user input regex in the following forms
/regex|here/i
/regex|here/
...
-1
votes
0answers
20 views
How to use mmap to read one string at one time? [closed]
The following code reads a very large file (of the order of 5 Gb) that contains different strings at each line. However, the method used in the following code reads one character of the file at one ...
1
vote
2answers
51 views
Regex to match strings safely
The following regex is meant to improve stringmatching by sanitizing the user -defined commandPrefix and checking for whitespace and line-endings after the ...
0
votes
0answers
47 views
Parsing JSON in one go
I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to ...
-1
votes
0answers
33 views
creating this string representation for this puzzle [closed]
i am trying to make this jigsaw puzzle. class is jigsaw and im trying to import this script called Piece.
...
-3
votes
0answers
26 views
Why does C output image data as characters but not as string [closed]
I'm trying to get an image file to be stored in a buffer of char *string to be later used in a function that takes a char * as a ...
1
vote
1answer
47 views
0
votes
2answers
58 views
JSON string parsing
I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to ...
3
votes
3answers
51 views
2
votes
2answers
41 views
splitting multiple joined words, port from perl to PHP
Though i have never worked on perl, not even once.
I have ported the perl code into PHP and it seems like giving a correct result. But as I am going to use it on production server.
I want this code ...
1
vote
3answers
75 views
Duplicate Line Finder
I recently wrote a program that reads a plain text file, and compares every line and alerts you if any are similar, based on a float value that you pass in to a function.
...
2
votes
2answers
40 views
Text 'guesser' / tumbler like animation
I made a tumbler thingy...
Do you see possible bugs in the code or any improvements I could do?
...
3
votes
3answers
758 views
StringBuilder vs string.concat
I was reading this article about StringBuilder vs string.concat and couldn't figure out which one would be better in the ...
6
votes
4answers
238 views
Numeric integrity check
I'm a beginning C programmer. I need a function that will take a string and determine if it's a number. The data is coming from files created by different people and the number formats WILL vary. So ...
10
votes
1answer
304 views
Implementing a String class using reference count
Design a STRING class. Provide support for:
Assigning one object for another
Two string can be concatenated using + operator
Two strings can be compared using the relational operators
...
1
vote
2answers
38 views
Anchor Text String Transformation in Swift
I need to convert a string using these rules:
Downcase the string
Replace spaces, a blacklist of "invalid" chars, and non-ascii letters (like é) with -
Replace ...
0
votes
1answer
39 views
Parse a string to get a SectorId
In mobile phones technologies, a SectorId is a 128-bit value broadcast by a 1xEV-DO BTS system.
That is a 16 bytes data.
I made a structure to store them:
...
4
votes
4answers
194 views
Changing a character in a string at a specified index position
Could you please tell me what you liked or may have disliked about this code? What can be made better?
...
7
votes
3answers
3k views
Replace space with %20
This is not very memory-efficient. Can you please suggest a better way or improvement?
...
9
votes
5answers
2k views
Check if a string has 20 numbers in a row in it
My code will check if the variable myString has 20 running numbers. I'm new to JavaScript and I'm wondering if there is a simpler way to do this. How can I shorten ...
1
vote
1answer
53 views
Converting bytes to an escaped hexadecimal string
I wrote this function to convert an array of bytes to a C/C++ string representation using hexadecimal escape codes (\xhh). Any suggestions are welcome:
...
2
votes
1answer
57 views
String similarity calculation
For string similarity, it is defined as longest common prefix length. For example, "abc" and "abd" is 2, and "aaa" and "aaab" is 3.
The problem is calculate the similarity of string S and all its ...
4
votes
1answer
41 views
3
votes
1answer
55 views
Check string having unique character or not without additional data structure
Here is my code without using additional data structures. Assuming all the characters are alphabetical and character checks are case-insensitive.
...
2
votes
0answers
45 views
Converting Chess FEN Notation to a Tuple and Back
This module is going to be part of a larger ElixirChess library for validating chess positions and moves, but I started with the core of it which is parsing a ...
1
vote
1answer
120 views
Converting from strings to byte arrays with LINQ in C#
I'm taking in a string of input from the command line, and when prefixed by 0o or 8# interpreting it as an octal string. I'd ...
4
votes
3answers
83 views
Java 8 String Unique Permutations in Parallel
Is there a better way to do this Java 8 String Unique Permutations in Parallel
...
5
votes
1answer
273 views
Longest Substring in Java
This is my function for determining the Longest Substring between two strings in Java.
...
4
votes
4answers
343 views
Expanding compressed string
I wrote this for a problem in one of the online contest at hackerearth. Problem statement is:
Input:
The first line contains the compressed string in form a2b4h5a2
Expanding it ...
3
votes
2answers
59 views
Comparison function for strings
I got a function that has as input 2 strings, computes the string similarity of all the combinations and give back and output the highest similarity. For example, "you are" and "are you" will have 1 ...
-1
votes
1answer
46 views
JavaScript function to compare strings
I've written this function for to check if two strings are equal.
Can I improve it?
Is there a better way to accomplish the task?
...
1
vote
0answers
20 views
Reformatting a structured string like “a-b-c|A-B-C” into “a-A|b-B|c-C”
The code below was inspired by this post in Code Review.
Here is how it was first intended by its author:
I have the following code that converts a string that looks like :
...
2
votes
1answer
62 views
Convert #hashtagstylephrases to a proper list of words
I'm writing a program to split the words contained in an hashtag.
For example I want to split the hashtags:
#Whatthehello #goback
into:
...
2
votes
1answer
55 views
Process string vector and change each string to uppercase
The question below came from C++ primer 5th edition.
Read a sequence of words from cin and store the values a
vector. After you’ve read all the words, process ...
4
votes
2answers
55 views
Library assistant
HackerRank currently has '7 days of JavaScript' going, a quick intro into the JavaScript language. Every day a couple of challenges will be made available. One of the challenges of today was this:
...
3
votes
6answers
516 views
Find the letter 'z' within three characters after an 'a'
It works, just feel that my solution is too complicated.
...
3
votes
1answer
45 views
Generate String with Random Consonants and Vowels
Purpose
This problem comes from this dailyProgrammer subreddit challenge.
The task is to take an input of C / ...
5
votes
1answer
127 views
Vowels in a String are in Alphabetical Order
Task
Write an implementation that returns whether a String has vowels (English language) in alphabetical (A-Z) order or not.
Feedback
Is my ...
4
votes
2answers
90 views
Calculating Garland Degree of String
Purpose
A garland word is a word
formed by chopping off the last few letters and “wrapping around” to the start.
For example: You can chop off the the trailing “on” from “onion” and still ...
4
votes
3answers
80 views
Command called 'sprinkle'
I have a command called sprinkle. I'm not going to explain anything about it, because I want whoever that reviews the code to also tell me how much of the command ...
6
votes
4answers
918 views
Random string generator
I decided to make a random string generator for fun, and it works for the most part. Since I'm an amateur at programming, I thought I would post the code to get some feedback on it, and hopefully ...
1
vote
2answers
90 views
Two and a sub string
Challenge:
Given two strings, A and B. Find if there is a substring that appears
in both A and B.
Specifications:
Several test cases will be given to you in a single file. The first
line ...
1
vote
1answer
65 views
Javascript startsWith prototype
I'm a Java guy in a JavaScript world, and I'm used to certain things about Java Strings that just aren't there for in JavaScript. Some of this I can accept, for example Strings are freaking everywhere ...
2
votes
1answer
47 views