Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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.

3
votes
2answers
19 views

Random quote rotator

On my website, I created like this banner that rotates quotes from an array I made. ...
-4
votes
1answer
65 views

A better way of splitting encoded data; RegEx vs String Operations?

The obvious answer here is to use RegEx for optimisation but I thought someone might like the challenge during their lunch break. The reasons for why I'm decoding these strings would make for a whole ...
2
votes
1answer
33 views

Convert string of hex into vector of bytes

I want to write a function that gets a string of hex numbers (two hex numbers represent a u8 value) then returns a vector of u8 ...
0
votes
1answer
14 views

Embolden parts of auto-complete suggestions that don't match the query

I made a function to embolden text that doesn't match a string, but it appears to be very performance-heavy. I am certain that there are much better ways to do this, but with what I tried, I ran into ...
2
votes
0answers
28 views

Madlib CLI program, replaces string in text file

Mad Libs program that reads in text files and lets the user add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB appears in the text file. ...
4
votes
1answer
63 views

Multiple client TCP stream reader

My server code is currently reading String data over a TCP connection form 2 different client computers. To do this I am duplicating the ...
3
votes
2answers
32 views

Utility functions for processing tweets or texts

I have 4 functions that process texts or tweepy.models.Status object (this object stores text information, author information, retweets & likes information of a ...
6
votes
2answers
293 views

Looping through a string finding nested brackets

So I've been trying to check through a string, looping for, [ (start) and ] (end). In this, I also have to check for nested ...
0
votes
1answer
43 views

Shuffle a string in a repeatable way

The following function is designed to accept a string of characters and an integer. The function returns a string that's a reordered version of the original string. The reordering process is ...
5
votes
3answers
201 views

Function for creating unique strings for urls

I wrote this function in order to create unique url's for my site. Using these urls, visitors could demo site functionality without having to create a login. The function was intended to return a ...
4
votes
3answers
52 views

Replace $number with $number+1 in std::string

I want to detect $number substring in std::string and then replace it with $number + 1. For ...
2
votes
1answer
28 views

Search and Replace (FreeCodeCamp intermediate algorithm scripting)

I completed the challenge and passed the tests: Perform a search and replace on the sentence using the arguments provided and return the new sentence. First argument is the sentence to perform ...
1
vote
1answer
28 views

Bool function in PHP to check if you run the script inside docker

I had to do a CLI script that does something, I also had to add a validation that checks if it runs inside the Docker. After a research I found a solution that people check some processes via ...
4
votes
5answers
160 views

Use filename to determine file type

This is legacy, so I'm not really looking for improvements on architectural approach. Here's what the method does: Extracts filename from a string containing full file path (passed in as parameter) ...
10
votes
1answer
537 views

string length in x64 assembly (fasm)

Please critique this very, very basic routine which returns the length of a given char buffer or "string." ...
0
votes
0answers
65 views

Minimum Window Substring in JavaScript

I find this Substring Leetcode challenge online. Given a string S and a string T, find the minimum window in ...
3
votes
2answers
117 views

Attempt at checking whether two words are permutations

This is my first algorithm in C++ ever to check if two strings are permutations of each other. Please provide guidance on correctness of algorithm + ways to improve + thoughts on my use of the ...
5
votes
4answers
122 views

In-place reverse of C-style string

This is a question from the book "Cracking the Coding Interview". Write code to reverse a C-Style String (C-String means that “abcd” is represented as five characters, including the null ...
6
votes
2answers
1k views

Generating a unique key

I am coming from a Ruby background and I am learning Python. This is a method I've created to generate a URL safe unique key: ...
1
vote
2answers
42 views

Apply capitalization of one string to another

I want to take the capitalization of one string and apply it to another. For example: take Apple and orange and turn that into <...
0
votes
1answer
60 views

Reversing the vowels in a String

Given a string, reverse only the vowels present in it and print the resulting string. Input: First line of the input file contains an integer T denoting the number of test ...
2
votes
3answers
81 views

Converting objects into JSON and using the StringBuilder

In my scenario I have list of object in C# code and need to be converted into JavaScript object. But there are certain condition, where the value of the object might be dynamic based on certain key. ...
0
votes
1answer
50 views

Hackerrank ransomnote

This is the question; https://www.hackerrank.com/challenges/ctci-ransom-note/problem I have solved this hacker rank challenge but i feel like the complexity is pretty inefficient because i use two ...
2
votes
1answer
41 views

Finding a swimmer's competing position from a website

This is a code that allows a swimmer to know his position with respect to other competitors. It gets the swimmer's time from the meet's website, finds other competitors' times and shows the better ...
2
votes
1answer
44 views

Anagram checking implementation

Given two strings, check whether two given strings are anagram of each other or not. An anagram of a string is another string that contains same characters, only the order of characters can be ...
-1
votes
1answer
46 views

Check Unique Chars in A String

Two solutions to check if a String contains unique characters. Wanted to know if these solutions can be optimized further. The Code: ...
7
votes
4answers
268 views

Remaking std::to_string in C++ with UDLs (User Defined Literals)

I would like some feedback on what I should change with my semi remake of std::to_string with UDLs (user-defined literals). This is compiled and working on linux ...
8
votes
2answers
390 views

Replace all the occurrence of a string

I have the following function to replace all the occurrence of a string that matches certain token. ...
4
votes
1answer
49 views

Code to implement the Jaro similarity for fuzzy matching strings

Problem This code is meant to solve the problem in this software engineering question. To summarize the issue: given a set of strings that are sort of similar, but not similar enough to use regex ...
10
votes
3answers
2k views

Generate 10 random 3-letter strings

This is a toy project and I am a beginner in Python. I need to create 10 random 3-letter strings, where characters are a - z. ...
1
vote
1answer
99 views

All subsets of a String in java using recursion

I wrote this code for printing all sets of a String. It also prints the empty subset. Is this the right approach ...
6
votes
2answers
198 views

Generic Case Converter

After receiving advice from my last question, I reworked the design of my program to be more generic, expandable and easier to use. This is the excerpt of the requirements: Step 1: Basic Title ...
4
votes
5answers
196 views

Sort string's characters into alphabetic order

Any improvements that I can make with this code? Also, is there another way to convert a vector to a string variable without using a for ranged-based loop? From the posts I've seen for converting, I ...
0
votes
2answers
151 views

Find the longest word in a sentence [closed]

This is my second attempt after I started to learn about STL. I am oblivious and need suggestions/advices on if there can be improvements made on this code. ...
12
votes
3answers
3k views

Codewars: Reduce strings to one character

I am trying to solve a puzzle in a performant way. This is the puzzle. Simply explained: you have a String and you must reduce it to one character with the given rules. This is the solution to the ...
7
votes
1answer
289 views

Given a string, find the length of the longest substring without repeating characters

I wrote an algorithm that solves this problem but I would love to get some feedback on it (especially since I'm not so confident in my Big \$O\$ skills). Do you think this is a good quality algorithm?...
10
votes
2answers
542 views

Title Case Converter

I wrote a program that, given a string of text, converts it to Title Case based on certain criteria. I would mainly like to know how I could improve readability and expressiveness, make a more clear ...
2
votes
1answer
73 views

Function to check whether two strings are similar at given %

Since the previous question I posted here was not found as interesting as I expected, I decided to post a new one. I made a function solely for the purpose of having fun. That is, a function that ...
1
vote
2answers
86 views

Reverse words in a string without affecting space

I came across a problem that needs to reverse each word in a string without affecting space in it. For example, if a string has two spaces between the word, the answer needs to have space between two ...
2
votes
2answers
345 views

String Swap-case one-liners (6 ways)

I did this small project where there are six one-liner anonymous methods that can swap case of a given string of any length. For example "heLLo, woRLd" ==> "HEllO, WOrlD". I used this string as the ...
7
votes
2answers
2k views

Emulating C++ string input in C

I did the following exercise: Write a C program that does the equivalent of C++ string s; cin>>s;; that is, define an input operation that reads an ...
7
votes
2answers
59 views

Bash evaluation using crazy passwords

I have some code that is loading passwords from AWS SSM and then using them through the script. I am really concerned that some funky password character is going to be used that is going to get ...
6
votes
1answer
36 views

Reformatting Latin vocabulary sets from The Bridge

I am currently studying Latin from Wheelock's Latin. Given that a core component of language learning is memorizing vocabulary I needed somewhere I could memorize vocabulary, online, namely Quizlet (...
3
votes
2answers
76 views

Simple program to detect the number of times a vowel occurs in a string

I wrote a simple program to print out any vowels found in a string, as well as the amount of times that vowel occurs. Here is my code: ...
3
votes
2answers
57 views

Extracting address information from non-formatted text

I'm pretty new to large projects, and usually my code is neat and manageable. But now that I'm about a month deep, things are starting to seem sloppy (or at least not aesthetically pleasing). Are ...
4
votes
3answers
100 views

Histogram of letters in string

I'm pretty new to Java and I've been trying to use top-down design and make my code very readable, so I would appreciate any comments as to the clarity and efficiency of this program. Looking for ...
4
votes
2answers
71 views

K&R C book - exercise 3.3

I have an exercise in my ANSI C book: 3.3. Write a function expand(s1,s2) that expands shorthand notations like a-z in the ...
4
votes
1answer
144 views

Splitting URLs into hierarchy-level directories

The goal is to split a URL like http://q.com/a/b/c to: ['http://q.com/a', 'http://q.com/a/b', 'http://q.com/a/b/c'] My code: ...
2
votes
1answer
563 views

Improvement in file management system based on the file names

Context: I have a program which stores data to the disk. The data is then reprocessed during some of the iterations. Thus, it needs to store, search and load set of data. Let's consider the ...
2
votes
2answers
168 views

Given an integer n, generate the nth count and say sequence

I am solving interview questions from here. Problem : Given an integer n, generate the nth count and say sequence. The count-and-say sequence is the sequence of integers beginning as follows: <...