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
0
votes
1answer
26 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 ...
4
votes
2answers
48 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 ...
-3
votes
1answer
58 views

Comma Code (from Automate the Boring Stuff) [closed]

I've read some other people's answers here but I'm confused why that level of complexity is necessary. Could anyone tell why the the following code does not fulfill the task? Thanks :) ...
2
votes
2answers
69 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
51 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
57 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
1answer
26 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
95 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
vote
1answer
87 views

A Tiny Text File Read/Write class Implementation in C#

I am trying to implement a tiny text file read / write class FileIO in order to make the operations of reading / writing pure text files easily. The usage is like: <...
0
votes
3answers
135 views

Convert first letter of every word to uppercase

I am learning swift and I came across this problem. Converting each start letter to capitalized form if it's lowercase. ...
2
votes
1answer
22 views

Input any time, output timezones that are currently that time

I made a program that will take in a time and a weekday, and return which parts of the world are at times closest to the one specified. Part of the program focuses on extracting a date and country out ...
2
votes
2answers
78 views

A Sub-string Extractor with Specific Keywords Parameter Implementation in C#

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

Identifying indices of non-delimited characters in a string, supporting greater than 1 length of delimiters

The code below takes a string that potentially contains a true match for a delimiter. There can be multiple delimiters located anywhere in the string. We need to obtain the indices that are not a ...
3
votes
1answer
60 views

strstr implementation with python and sets

Please review my strstr implementation in terms of time/space efficiency and overall readability. I am preparing for a coding assessment coming up as I am looking to pivot my career from Physics to ...
5
votes
0answers
38 views

calculating upper bound on normalized weighted levenshtein distance

Current implementation I am using a normalized weighted Levenshtein distance for two utf32 strings with the following costs (insertion: 1, deletion: 1, replacement: 2). The normalization is performed ...
-4
votes
1answer
53 views

What does %s mean in a python strings? [closed]

I'm not sure what %s means in Python strings. I came across this line of code somewhere a while ago: ...
1
vote
1answer
47 views

Rust - insert into piecetable

I'm writing a piece table library in Rust with the structures: #[derive(Default)] struct Piece { additional: bool, offset: usize, length: usize, } and <...
6
votes
1answer
354 views

Capitalizing the first letter of every word in a string (with arbitrary spacing)

I solved the following question You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised ...
4
votes
2answers
97 views

Converting a string into an array and returning the values spelled in reverse

I must create a function that accepts a string of names all separated by a comma. Example: "Jack,Matthew,John,Sam" And return the string of names in the ...
20
votes
4answers
2k views

Add 'ing' or 'ly' suffix to a string

I have been practising Python Practice questions and came across this question: Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string ...
6
votes
0answers
122 views

Generate unique random strings considering collisions

I'm coding a random strings generator. It's working, but I'm not sure if this is efficient. ...
5
votes
2answers
72 views

Log file name adjustment

I have the following code that takes user input "path" and adds the current time into the filename after the name part and before any extension (if it exists). It seems a little hacky to me ...
4
votes
1answer
160 views

Finding Pattern Score in Python

I saw this problem in C++ on here and decided to try it in Python, which was much simpler. I've used the same problem blurb as in the link above, so they are consistent. I'm sure my code can be ...
3
votes
3answers
65 views

Concatenating optional strings in Scala

I have two optional strings, any of them can be None. I want to create their combination with a delimiter between them if they both exist. I expect to be able to come with a more concise and nicer ...
1
vote
2answers
85 views

Sorting string with if-else

I was asked to write a program that sorts three strings alphabetically using only if-else (no sorting algorithms, usage of arrays whatsover). I'm fairly new to C++ programming but I've come up with ...
5
votes
1answer
113 views

LeetCode 1638: Count Substrings That Differ by One Character

I'm posting a solution for LeetCode's "Count Substrings That Differ by One Character". If you'd like to review, please do. Thank you! Problem Given two strings s and t, find the number of ...
5
votes
4answers
132 views

String concatenation challange to be more efficient with DayOfWeek and Lists

I have this challange that I finished which asked to print out a string according to the provided schedule. Here is an example: ...
0
votes
1answer
72 views

Generate unique string permutations recursively

🧩 Objective Write a recursive method for generating all permutations of an input string. Return them as a set. See: Recursive String Permutations - Interview Cake 🔎 Questions 1: How does the ...
6
votes
2answers
217 views

String/text manipulation utility class

I'd like to get some expert's view on this first piece of code especially in the area of performance - (e.g. avoidable copies) good practice (e.g. static members?) The final goal is the provide some ...
4
votes
3answers
214 views

Microsoft OA | Longest Substring Without 3 Contiguous Occurrences of Letter

For the following question, does my JS Solution seem correct? I'm looking for some peer review. Q: Given a string s containing only a and b, find longest substring of s such that s does not contain ...
9
votes
1answer
195 views

LeetCode on Longest Palindromic Substring in Python

This is a programming question from LeetCode: Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is ...
8
votes
3answers
293 views

Creating Two-Dimensional String Array for Plane Seats

I'm creating a ticket reservation system in Java, I want to use a Two-dimensional String array for managing the seats. I have enums that hold the plane model and the amount of seats available so the ...
7
votes
2answers
542 views

Number of occurrences of strings in array

This is a Hackerrank problem (https://www.hackerrank.com/challenges/sparse-arrays/problem). We're given an array of strings and an array of queries, and have to return an array of the number of ...
4
votes
1answer
70 views

Processing delimiter characters in C?

Write a C program that will implement the basic operations of table processors. The input will be text data read from a .txt file, operations will be defined using terminal arguments, and the output ...
4
votes
4answers
300 views

Convert Integer to Binary String

This code takes a user input number which is a positive integer, and outputs a string representation of the number in binary. For example, input 2 outputs ...
4
votes
1answer
235 views

Get parent path

I am trying to write a function that would do what a cd .. would do. Basically get the parent of the given path. eg: ...
7
votes
4answers
1k views

How can I efficiently manipulate digits in a string without using RegEx in Java?

I am reading a book with different quizzes about coding interviews. Please implement a function that increments a string based on the rules below: It should take the string of unknown length and ...
6
votes
4answers
927 views

First non repeated character

Problem Statement : Print the first non repeating character in a string. Example : In the string somecharsjustdon'tliketorepeat, ...
3
votes
3answers
81 views

Initializing an array of string constants, and another constant array of the equivalent lengths

Ok, a struct would actually be most convenient, but it woudl be easier on teh system to have 2 seperate arrays rather than an array of structs. ...
2
votes
2answers
83 views

String Mutator performance

I've made a very basic wrapper over a String that offers mutability in place (context: mono/XNA, budget is about 11ms per frame, 0B (ZERO, NIL, НОЛЬ, NADA) allocations hard requirement). Before that I'...
9
votes
4answers
883 views

StringTokenizer for .NET Core

Splitting a string in tokens is a more complex topic than String.Split() wants to make us believe. There are at least three common policies according to which a string might be interpreted and split ...
2
votes
1answer
62 views

Converting an integer to a hexadecimal string representation in Java

I have rolled my own Java method for converting ints to the hexadecimal Strings: ...
6
votes
2answers
106 views

Hide certain email characters

Hide email characters: When email only has one letter then just cover that letter with the * symbol e.g. *@gmail.com When ...
4
votes
3answers
459 views

String class implementation

I'm working on a project (it's a language), and for that project, I decided to go with a low-level C++ style, so that means making my own data types. I recently got done making my own string class ...
3
votes
0answers
64 views

Early Stages of floating point class template in C++

I'm currently designing a class template to represent scientific notation or a floating-point number system. There are currently 4 distinct types: BIN, ...
5
votes
4answers
259 views

C#: Repeated String

From HackerRank "Repeated String" challenge: Lilah has a string, \$s\$, of lowercase English letters that she repeated infinitely many times. Given an integer, \$n\$, find and print the ...
5
votes
1answer
94 views

Similarity between words

I'm writing a method that writes the code for a loading routine. Given an object from the database, I want to put its properties in the right control on a userform. I have the list of the properties ...
6
votes
2answers
84 views

My first C# project - Simple bird of prey identification console app. Does it need refactoring or complete rewriting?

this was my first thing i made on my own without any help. im sure theres a lot of improvement that could be made, i dont feel too confident about this. how can i make it shorter and more efficient? ...
4
votes
1answer
89 views

LeetCode: Find And Replace in String C#

It took me a while to solve this question and there are corner cases i missed hence the 4 unit tests. please review for performance. and if you can treat this as a review for a 45 mins programming ...
1
vote
0answers
34 views

Custom include? method for a substring

Task: Write a function which returns true if a given substring is found within a given string. If the substring isn't found, then return false. My implementation: ...

1
2 3 4 5
54