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.

Filter by
Sorted by
Tagged with
1
vote
1answer
75 views

Calculating the seconds between 2 numbers in a specific place in a string

We have a ...
3
votes
1answer
146 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
910 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 ...
7
votes
0answers
44 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 ...
6
votes
1answer
78 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
25 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
43 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
49 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
117 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
47 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
69 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
35 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
55 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
101 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
59 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 ...
3
votes
2answers
49 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
435 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
381 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
137 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
67 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
158 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
49 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
26 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
569 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
556 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
30 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
74 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
69 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
147 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
700 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
75 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
20 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=...
-1
votes
2answers
119 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
84 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. ...
19
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
2k 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
43 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
96 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
74 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
60 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
553 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
89 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 ...
3
votes
2answers
198 views

Counting the number of ways to decode a string

I am working on problem where I need to decode a string: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... ...
5
votes
3answers
120 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
150 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
48 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
39 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
407 views

Remove excessive whitespace from string [closed]

Is that standards-compliant? ...
3
votes
1answer
104 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 <...