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.

14
votes
3answers
2k views

Count all vowels in string

For a homework assignemnt, I was asked to complete this CodeStepByStep problem. It's coded correctly and gave me a right answer. I'm just wondering if there's an easier way to solve this problem ...
-1
votes
0answers
25 views

How to count the number of occurrences of english word and chinese character in some files? [on hold]

How to count the number of occurrences of english word and chinese character in some files? I want to implement a function through Node.js: count the number of occurrences of english word and ...
2
votes
0answers
25 views

Faster way to replace strings in pandas series using dictionary in Python

I'm working with a dictionary with 11830 keys/values, that have to loop over 13905 strings, that can have up to 50 words each. My series looks like this: ...
5
votes
1answer
84 views

Identify fraudulent bank transactions

Task: Return true if a transaction is allowed and return false if transaction is prohibited. Details: 1. String is represented as an "array" that can contain up to three elements. We need to ...
4
votes
1answer
46 views

Preperiodic, periodic or aperiodic binary string

This is extension of the rep-string task from Rosette code. I do not only want to check if the input string is the shortest periodic string (rep-string) or not, but also check if it is preperiodic. ...
1
vote
2answers
49 views

Optimize printing massive strings to System.out with respect to time

I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead ...
-4
votes
0answers
22 views

Lambda function in sorted() [closed]

This code snippet is copied from here. It is Rail fence cipher. I can't understand what the last return statement(the one in encode function) does. ...
5
votes
2answers
315 views

Search string in file, replace it, and write back to file

I have this simple function that just reads a file, replaces all occurances of a string, and write it back to the file: ...
-3
votes
0answers
27 views

Trouble with adding string to a linked list, c++ [closed]

I added an integer to a linked list with no problem but when I edited the node class to add a string I keep getting an error. Any and all advice will help Linked List Class: ...
5
votes
2answers
742 views

Find hamming distance between two Strings of equal length in Java

I have a private class that I want to be able to find the shortest Hamming Distance between two Strings of equal length in Java. The private class holds a char[] ...
5
votes
4answers
283 views

Determine if a string only contains repetitions of a substring

This is my first Python program in years, it's just a simple string manipulation program. Given a string, determine if it contains repetitions of any substring. For example, ...
3
votes
1answer
41 views

Extracting small word parts (quadgrams) from text using R

I would like to extracts small word parts (quadgrams) from text. Example: hello world results in: ...
11
votes
4answers
750 views

Cropping a message using array splits

I am trying to write a simple function to crop a given message to a specific length but at the same time not to cut the words in between and no trailing spaces in the end. Example: Input String: ...
7
votes
3answers
86 views

Static utility class for string manipulation in C++

My programming foundations were formed in Java, but I've decided to only use C++ from now on for my projects as a personal learning experience. Static utility classes are common in Java; but I don't ...
6
votes
2answers
306 views

Generating 10-character passwords, with 3-6 digits and 3-6 uppercase letters, in C++

In response to a question on Information Security on brute-forcing passwords, I wrote code that helped solve the problem: Generate a password list of 10 character passwords containing only a ...
2
votes
1answer
34 views

Determine if an array of arrays of characters can be concatenated in order, into a substring of haystack

Algorithm: Determine if an array of arrays of characters can be concatenated in order, into a substring of haystack. Example: ...
9
votes
2answers
486 views

Extracting the parent, leaf, and extension from a valid path

Powershell has the Split-Path cmdlet which allows you to extract the Parent and Leaf of a file. In PS version 6, you can extract the extension, with the ...
2
votes
3answers
149 views

Armstrong number generator

This is my code to generate all possible Armstrong numbers between the two given numbers. The logic uses string instead of integer to separate the digits to optimize the code. ...
-2
votes
2answers
140 views

ArmstrongNumber checker

This is my code written to check whether a given number is armstrong or not . but the logic differs from the conventional logic of using integer and separating its digits and calculating , instead i ...
1
vote
2answers
36 views

Trimming strings in non-contiguous spreadsheet ranges

This code is tested and works, but I am needing some guidance on simplifying these loops with non contiguous ranges. I was thinking an array might be better, but I ...
3
votes
1answer
144 views

Splitting a long string based on its graphical presentation

I got a long string, let's call it Story. I fetch this story from a database so I don't know how long it is. I want to display this story in a view, but what if ...
1
vote
1answer
74 views
3
votes
1answer
120 views

Python snippet for finding word in string

I wrote a simple function that finds a word in a string without use of the re module. My function looks like this: ...
6
votes
3answers
679 views

Reverse the word in a string with the same order in javascript

I want reverse the string with the same order. We should not use the Array functions like split(), .reverse() and some other array functions also except ...
6
votes
0answers
37 views

Checking whether a string fragment could be part of a longer UTF-8 string

Although UTF-8 validation is a common task, I'm trying to solve a slightly different task; given a string of bytes, work out whether it could potentially be a fragment of a valid UTF-8 string. That's ...
5
votes
1answer
64 views

Rendering tree of nodes as string

I'm creating a debug-view for my expression-trees. They record each operation automatically in a tree that I am transforming into string so that I can see the exact ...
1
vote
0answers
22 views

Average histogram combining multiple files and vector of vectors (in c++)

I run a program of simulation N times (I use each time a different random numbers to initialize it). The results of the program are stored in 2N directories: every run produces two approximations. The ...
1
vote
1answer
41 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
35 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 ...
2
votes
1answer
30 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
102 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
44 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
67 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
34 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
51 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
99 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
2answers
55 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 ...
2
votes
1answer
29 views

Check for pangrams in elisp

I'm trying to find pangrams ie sentences that contain all the letters of the alphabet, for instance "The quick brown fox jumps over the lazy dog". I'm an absolute beginner in elisp, and it ended up ...
9
votes
2answers
427 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
364 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
123 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
45 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
147 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)...
1
vote
1answer
46 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
24 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
428 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
553 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
26 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
73 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
68 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 ...