Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [strings]

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.

0
votes
0answers
8 views

Prints information about a restaurant (provided by user input) using a .txt file

My code works, but not the way I want it to. If a user provides a string, even if the string doesn't match a name in the array, it will print information about all 5 restaurants. If I put a break ...
1
vote
1answer
33 views

Bubble sort in C (for strings)

What do you think of this bubble sorting function in C, for a string array? I would like to improve the readability, performance, and any good practices. ...
0
votes
1answer
21 views

Building complex sentences based on a data structure

I really do not like how bad this looks. It is not readable and I am not sure if I need the stacked map's. There are a lot of iterations going on here (map, join, replace) and performance is really ...
1
vote
1answer
21 views

Converting words/numbers to Discord “letter/number emojis”

I am a beginner to Python (and programming overall) and I decided that it would be funny if I wrote a program that could convert Letters/Numbers to these "Letter Emojis" in Discord. It works but I am ...
2
votes
1answer
90 views

Game to shuffle and guess a word

I'm new to C++ and while learning, I wrote a simple program that asks for a word, shuffle sthe characters and then asks another person to find the original word, given the shuffled letters. I would ...
1
vote
1answer
40 views

Efficient way to add a colon before and after every word in strings inside a Series

I was working with twitter data, and extracted every emoji from the data. But, when I passed that data through CountVectorizer, colons where substracted from the ...
0
votes
1answer
58 views

Combinational string search using Java

I wrote a program that receives 2 strings (Input and Search) in the Search string. The sign '+' indicates that if the substring before the '+' exists in the Input string. (The search string cannot ...
4
votes
1answer
29 views

Count words in a list of titles, with some cleanup

I have a list of article titles, where I wish to count the number of occurrences for each word (and remove some words and characters). The input is in a .csv file where the titles are in column '...
4
votes
2answers
48 views

String joining function in C

I wrote a function that joins a collection of Strings with a delimiter. It's based on Java's version of the function. I'm assuming C has some similar built-in. Example: ...
3
votes
4answers
93 views

Linux wc command in C

I'm working on my implementaion of the linux wc command. I finally have something that is working properly (with no options yet) but i think it needs a lot of "cleaning". I mean, i highly disrespect ...
2
votes
1answer
41 views

Keep ABC size down for conditional string concatenation in Ruby

This method takes a comment object and displays it correctly depending on what columns are available. EVENT_TEXT and REASON_TEXT ...
9
votes
2answers
424 views

A function which translates a sentence to title-case

The task is to write a JavaScript-function which translates a given blank-separated sentence to title-case. Means that all words shall start with a capital and then the rest of the word in lower-case....
8
votes
4answers
354 views

strToHex ( string to its hex representation as string)

I want to convert strings to their hex representations as strings too (like hex dump programs), for example "abz" to "61627A". ...
4
votes
2answers
114 views

strTok function (thread safe, supports empty tokens, doesn't change string)

I'm new to C language and want to explode a string like we do in PHP explode() function, I searched for a built-in function with the C standard library, and I found ...
1
vote
1answer
43 views

Advanced love calculator that generates a result based on the similarities between the two names

My love calculator gives a result from 0 to 100% based on these factors: If the first letters of the names are the same. If the number of vowels is the same. If the length of the name is the same. If ...
2
votes
2answers
110 views

Consecutive words match in a dataset

I have written an algorithm to do consecutive word match in a dataset The input is a dataset (list of textlines) and I want to scan that and return repeated word(s)...
0
votes
0answers
36 views

strReadLine function (read line by line from a string)

I'm new to C language and want to read a string line by line, I made this function and want to know what do you think about it, can I rely on it a production environment ? ...
1
vote
0answers
23 views

Sort an array of strings using bubble sort

I have this following code to sort an array of strings order by ASCII value (alphabetically) using bubble sort. ...
6
votes
3answers
406 views

Elegant way to replace substring in a regex with optional groups in Python?

Given a string taken from the following set: strings = [ "The sky is blue and I like it", "The tree is green and I love it", "A lemon is yellow" ] I ...
15
votes
3answers
540 views

Modify casing of marked letters

Trying to learn coding in my 30s. Could anybody review my code and give me some feedback if possible? It works, but I am sure there are better ways to solve this problem. The problem: A text is ...
2
votes
0answers
25 views

Finding the numerically listed string to the center algorthim

The algorithm takes input for a string's length for L, and the number of strings altogether for X. The hamming distance is for input D. Input Z calculates the exact amount of all possible characters ...
3
votes
2answers
72 views

Extracting all-caps variables from string expressions

I'm extracting variables from user entered mathematical expressions, so that I can enter them into the expression evaluator exprtk. For now, the condition is given that variable names will be composed ...
2
votes
1answer
67 views

Ruby Beginner - Fuzzy matching / string manipulation

There is no intended end use for this. It is for learning and development only. I got carried away following an example and ended up with a miniaturised vehicle registration system. You can bulk ...
3
votes
1answer
80 views

C++ Console Menu User Validation

So I am trying to implement a menu in a program I am writing. My goal is to have zero errors when collecting user input. So I thought the best way to validate was to capture the input as a string and ...
12
votes
2answers
673 views

Calculate the frequency of characters in a string

I wrote this program to check the number of times that each letter appears in a string input by the user. It works fine, but is there a more efficient or alternative solution of going about this task ...
2
votes
2answers
72 views

Writing a ~100Kb HTML string over an MD file (number of iterations ~10K)

I have tried to write a large string (~100-120 Kb of HTML) on an md file, and am pretty sure it's not the fastest method, even though it only has to iterate ~8000-...
0
votes
0answers
15 views

Script that uses strings of text for introspective analysis

PDR is an acronym for Personality Defect Removal. This script was written in BASIC v1.1. I use strings to save details of the psychological analysis of one's defects to improve their personality. MIS=...
-2
votes
2answers
101 views

Sanitizing name strings using PHP

Functionality: This method removes a list of specific terms (e.g., LLC, INC, Inc, Company, etc.) from a list of public companies names. It is part of a class that can be viewed in this link. I'd ...
1
vote
1answer
53 views

Word count graph

I created a program in python that reads a file and outputs a frequency graph of the words it contains. Any feedback or tips would be appreciated. ...
20
votes
2answers
5k views

String reversal in Python

This code will take as output any string (long, empty, with spaces...) and will return its reverse. Can I improve this algorithm so that it can be faster? Right now its complexity is \$O(n)\$. <...
6
votes
2answers
648 views

Find a best fuzzy match for a string

I am trying to find a best match for a name within a list of names. I came up with the below code, which works, but I feel that the creation of the intermediate ...
2
votes
0answers
34 views

Not a very interesting implementation of a simple substitution cipher in Python

I know this has been done before, but I needed to brush up my Python skills. Also, I intend to publicly share this code on a blog post sometime in the near future. This is also an attempt to improve ...
2
votes
1answer
87 views

Simple pattern matching between two string inputs using Java (Google interview challenge)

The interview question is: Write a function isMatch (without using java.util.Regex) that takes two strings as arguments: ...
3
votes
1answer
69 views

Decomposing a matrix as a sum of two bitstrings

I chanced upon this question and came up with the following algorithm, looking for criticisms and advice on how to improve my algorithm efficiency. You are given 3 arguments: A & B are ...
0
votes
2answers
48 views

Search files content fast in powershell

I need to search a large repository of files for a specific resource, and return it only if it is used or not. It is working as expected, but it is very time consuming. To search for 50 resource ...
7
votes
2answers
523 views

Version of C# StringBuilder to allow for strings larger than 2 billion characters

In C#, 64bit Windows, .NET 4.5 (or later), and enabling gcAllowVeryLargeObjects in the App.config file allows for objects larger than two gigabyte. That's cool, but ...
2
votes
1answer
56 views

(Codewars): Find the Unknown Digit

Kata: https://www.codewars.com/kata/find-the-unknown-digit/train/python To give credit where credit is due: This problem was taken from the ACMICPC-Northwest Regional Programming Contest. Thank ...
5
votes
3answers
111 views

Confuse a text without making it unreadable

Scientists have found that a text can still be read even if only the first and last letter of a word are in their right place. The remaining characters within the word can be arranged randomly. ...
8
votes
1answer
141 views

A string_splitter using C++17

In this repo I've put together a header only string splitter, allowing for characters and string literals as delimiters. The (little) library is strictly C++17. I would like to ask for your comments....
2
votes
1answer
45 views

segstr - Get delimiter-separated segments from a string in a non-destructive method

I wrote my first useful function in C which can be used in a different variety of situations as an alternative to common code logic. segstr (originally named ...
1
vote
1answer
37 views

Random String Generation module in Python

The module is for facilitating random string generation. The example I use to explain it is the following: Instead of writing ...
3
votes
3answers
181 views

Remove excessive whitespace from string [closed]

Is that standards-compliant? ...
3
votes
1answer
79 views

C++ String class implementation

I wrote a simple String class implementation using unique_ptr and move semantics. Is my implementation good enough in terms of design and efficiency? Stringy.h <...
3
votes
1answer
43 views

Find a valid english phrase that is identical to what the user entered, save a missing consonant

The Task: The user enters a path to a dictionary file (one word per line) and a phrase as system arguments. My code must then find phrases containing only valid English words, generated by removing ...
3
votes
2answers
83 views

Splitting C string without modifying input

I wrote this after using strtok_r and needing something similar that can copy the input string and handle multiple characters in the delimiter. Its functionally ...
5
votes
3answers
94 views

My own getline function for reading strings from files

I am a newbie to C++ and I want to do some cool stuff with it. Here I have implemented my own getline function which reads from a file. so what do you think of this getline function? ...
5
votes
3answers
114 views

Functions to count vowels and consonants in strings

I am coming to a problem where I am writing a function that accepts a pointer to a C-string as its argument. The function should count the number of vowels appearing in the string and return that ...
2
votes
1answer
42 views

Concatenating an already existing filename to create a new file

I had answered this question from stackoverlow and the code below is code that I wrote to explain to the OP a possible way to achieve what I believe they were looking for. The general idea that I ...
8
votes
2answers
983 views

Concatenate words in such a way as to obtain the longest possible sub-string of the same letter

An array of N words is given. Each word consists of small letters ('a'- 'z'). Our goal is to concatenate the words in such a way as to obtain a single word with the longest possible sub-string ...
1
vote
1answer
71 views

Find out whether string A can be shifted to get string B

The task: Given two strings A and B, return whether or not A can be shifted some number of times to get B. For example, if A is abcde and B is cdeab, return true. If A is abc and B is acb, ...