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
2
votes
1answer
20 views

C code to reset all usb devices (because ubuntu laptop disables usb mouse after sleep)

I don't program much in c, but cobbled together some code from different places in google. I'm sure this is backwards especially in how it works with strings and directory files. Please let me know ...
1
vote
2answers
41 views

PHP strpos() as a way to implement an swear word filter

I wrote a short function that should check if user input does contain any bad words that I predefined inside $bad_words array. I don't even care to replace them - I ...
1
vote
1answer
46 views

Golang - Splitting a string by a separator not prefixed by an escape string

I need to split a string by a separator but don't want to split if the separator is prefixed by the escape string. For example: ...
1
vote
1answer
39 views

Unique elements, long runtime Haskell

I have two functions. Both have to have unique elements, one with Integers and the other a String which returns a list of ...
2
votes
2answers
96 views

C++ overloading += operator in custom string class better implementation

I am trying to learn C++, so I started coding a custom string class (using only c-style strings) to get familiar with concepts like operator overloading etc. in the case we have a pointer attribute. I ...
0
votes
2answers
24 views

Abbreviating a name

This is a question from a CS diploma question set : Make a program that will create an abbreviation of any given name using the initials. For example if the name if "John Doe", the program ...
0
votes
3answers
163 views

My safer strcmp

If used right, strcmp is not dangerous. However the code calling it might be. Limiting the opportunity for bugs I might in large teams "dictate" some kind ...
4
votes
3answers
84 views

Excel VBA code midStr() function using left and right position instead of length used with mid()

In the early days of Basic (1970's when i started coding) the midStr() function used left and right positions directly rather than left and length we now use with mid(). I always found it more ...
1
vote
1answer
33 views

Parsing glider data from IGC files

I have to do a program in PHP that reads IGC files like this IGC file and gets records about the glider. For now I came up with something like this: ...
6
votes
2answers
148 views

Flatten JSON to string

The code below is a Python module to flatten JSON-like structure (nested dictionaries and lists) to a single string. It also provides partial result in the form of flat list of strings. This ...
5
votes
3answers
91 views

C function that emulates string concatenation operator '+' in Python or Go

I'm working on a project of mine which required multiple calls to strncat(), and it came to me that it'd have been much easier if C also had something like ...
2
votes
0answers
29 views

Is there a better pattern to match those words with regex?

Hello StackExchange community, I am curious if there is a better solution than mine for this exercise below: Enter a regex that matches all the items in the first column (positive examples) but none ...
1
vote
1answer
91 views

Method encodes all less than (<) characters in a HTML string, but not the HTML tags

I am cleaning a HTML string to encode the less than sign (<) to a HTML entity (&lt;), but leaving the HTML tags as they are. An example is converting ...
4
votes
3answers
226 views

Split function using C and dynamic memory allocation

I have programmed a function to split strings, and it gives the expected output. I am looking forward to write better code and I was told here is a good place to start. Here's my program: ...
0
votes
0answers
29 views

A batch_recursive_count_if Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_count_if Function with Unwrap Level for Various Type ...
1
vote
2answers
68 views

Read strings from a standard input, and find the most duplicated word

Write a program to read strings from standard input looking for duplicated words. The program should find places in the input where one word is followed immediately by itself. Keep track of the ...
3
votes
2answers
80 views

Pluralize a string

I find that a common pattern when outputting a message is the need to pluralize a word. For example, if I need to output a count of files found I would need to write something like ...
20
votes
6answers
3k views

Password validator

I have made a password verification "program" which takes user input and checks whether the password is valid or not. Based on that, a reply is printed. ...
1
vote
1answer
27 views

Chunk a large set of characters by a specified set of delimiters and a maximum chunk size

Problem I need to be able to grab a subset of characters but ensure that each set doesn't exceed a specified limit and must end with a defined set of characters. For example, say I have an entire book ...
0
votes
1answer
45 views

Markdown table strings to two dimensional array converter implementation in C#

I am attempting to implement a converter which can convert List<string> type markdown table into two dimensional array ...
18
votes
6answers
4k views

A C++ program to check if a string is a pangram

I'm new to C++ and decided to implement a simple program that checks if a string is a pangram (i.e. the string contains all the English alphabet letters). It's my first program in C++ and I have some ...
0
votes
0answers
20 views

Boost.MultiArray Based Two Dimensional Array to Markdown Table Converter Implementation in C++

I am attempting to implement a converter which can convert two dimensional array (using Boost.MultiArray library) into markdown table. The experimental implementation ...
0
votes
2answers
61 views

A recursive function to reverse string

Write a recursive version of the function reverse(s), which reverses the string s in place. I'm studying K&R and wrote a code for the question. ...
1
vote
1answer
47 views

String tokenizer

Objective: Create a function called wordsAndSpaces that splits a string on groups of spaces, preserving each group of space characters as a single token. Example: <...
2
votes
1answer
148 views

Two Dimensional Array to Markdown Table Converter Implementation in C#

I am attempting to implement a converter which can convert two dimensional array (such as string[,]) into markdown table. The experimental implementation The ...
3
votes
1answer
39 views

Text replacement with Räubersprache (“Røversprog”)

I've been toying with Haskell again and implementing a simple text replacement program that replaces all consonants c in a text by coc, i.e., inserting an 'o' in between: ...
0
votes
0answers
34 views

A Tester of Paragraph Merger for Removing Overlapped Duplicated Lines in C#

This is a follow-up question for A Paragraph Merger with Removing Overlapped Duplicated Lines in C#. I am trying to implement a tester for testing the implemented paragraph merger for removing ...
0
votes
1answer
31 views

Write a Kotlin function “commonPrefix”

Task description: Write a function commonPrefix, which takes two strings as parameter and returns the common prefix. Example: parameters ...
1
vote
1answer
54 views

Separate an email address into its username and domain name

This is my first ever Python program and I wanted to get everyone's opinions on it. The goal of the program is to separate an email address into its username and domain name. ...
3
votes
2answers
109 views

Parse sequence of characters detecting formatting categories

I am a beginner coder and SonarLint tells me code is too complex. I tried recursion, iterators, slicing but had not luck making this code any simpler. The code will parse the input string to detect ...
4
votes
2answers
101 views

Retrieving top-level opening and closing sequences from a Python string

The problem I'm solving is a more complex version of pairing up opening and closing brackets. Instead of matching only on ([{}]), I additionally need to match ...
-1
votes
1answer
51 views

Finding longest word in a sentence

A problem from Coderbyte. Find the longest word in a sentence after removing the punctuations and if two or more words are of same length return the first word Below is my solution: ...
3
votes
1answer
78 views

Strlen function optimization

So I'm making a strlen function and I thought I would use SIMD instructions for it. It runs fine but when comparing it to std::strlen(), it falls a lot behind. Any ideas on how to make it faster would ...
4
votes
4answers
171 views

Limit fgets input to up to a certain number of characters

This question is an extension of this other question from Stackoverflow. The objective is to limit the input of characters read by fgets to up to a certain number of characters. And in the following ...
1
vote
1answer
45 views

Find Permutations of String in Scala

Given a smaller strings and a bigger string b, design an algorithm to find all permuta­tions of the shorter string within the longer one. ...
2
votes
2answers
49 views

Numeronym generation

Problem statement I need to generate numeronyms from a string, let's say qwerty as follows: qwerty q1erty q2rty q3ty q4y Code ...
2
votes
1answer
47 views

Javascript. Reverse order of words in string, but not special characters

Hello I am hoping someone can provide me feedback on my solution to this prob. If there are additional edge cases I should consider etc. Thank you! The question: "Given a sentence with a set of ...
0
votes
2answers
37 views

How to use string constants correctly

I often get into the dilemma of how to use string constants, this is the way I use now: ...
-1
votes
1answer
25 views

c++ convert all letters in the following text to uppercase and replace all vowels with the '#' character different format from last [closed]

how what am i supposed to make cout so the changes i make show up as the out put because putting a just shows the original string ...
6
votes
3answers
539 views

Generate random string to match the goal string with minimum iteration and control statements

The following is my python code to find the number of iterations needed to generate random string iteratively to match the input string. Here I have repeated a similar kind of for loop in both the ...
3
votes
1answer
90 views

Substring search in Java

I am trying to make an algorithm that will find the index of a given substring (which I have labeled pattern) in a given String (...
1
vote
1answer
74 views

A Paragraph Merger with Removing Overlapped Duplicated Lines in C#

I am trying to make a paragraph merger that takes multiple paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy. Each input paragraph is with the ...
1
vote
2answers
63 views

C text word-wrapping

I'm writing a program that has the possibility of outputting a large amount of text on a single logical line to the console. In that scenario, I would like to wrap the text at word ends so that words ...
2
votes
1answer
59 views

Extract string between first occurring set of parenthesis

I have this function and need to refactor it Please refactor the code below to make it more concise, efficient and readable with good logic flow ...
7
votes
2answers
102 views

Method to randomise a string's case

I'm an amateur at programming and have created the following method with which I pass a lowercase string with the idea it is then returned either in it's original ...
2
votes
2answers
77 views

Replace string based on multiple rules, don't replace same section twice

Given a 2-column CSV dictionary file that contains translation of certain words, this c# code needs to replace the first occurrence of a word in the dictionary. Once a segment of string has been ...
3
votes
1answer
60 views

A Sub-string Extractor Implementation with Given Vocabulary Words in Java

This is a follow-up question for A Sub-string Extractor Implementation with Specific Keywords in Java. As AJNeufeld's answer mentioned, the test case ...
4
votes
2answers
65 views

A Sub-string Extractor Implementation with Specific Keywords in Java

I am trying to implement a Java version sub-string extractor with "start keyword" and "end keyword" and the extracted result is from (but excluded) the given start keyword to (but ...
4
votes
2answers
69 views

Excel VBA Code for Imperial Length Measure Conversion and Formatting Yards Feet and Inches for English and Spanish

STR2INCHES is an Excel VBA Function that will convert string text for Imperial length measurements to a decimal number of Inches. It handles both English and Spanish words, abbreviations and symbols ...
2
votes
3answers
105 views

Convert string format python

I want to fix number of digits after '.' in digit represented by string. Is there better solution than mine? My code ...

1
2 3 4 5
54