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
1 answer
58 views

Split large strings into parts by last index of character and by max length

This is my method to split strings into parts by last index of character and by max length, the rationale for this method is because I have to send, in a payload via ...
user avatar
  • 123
0 votes
1 answer
47 views

Excessive space C++ string [closed]

Extra gaps A string is given. Write an application that will remove all extra spaces from this string. A space will be considered superfluous if: it is at the beginning of the line, before the first ...
user avatar
  • 1
2 votes
1 answer
141 views

Split string by last occurence of character within a range

So I would like to split a string in two by the last space within the first 40 characters, the best solution I could think of: ...
user avatar
  • 123
2 votes
1 answer
60 views

Text splitter using Regular Expressions in Python

I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list. I had an idea ...
user avatar
0 votes
1 answer
22 views

Modify a string by identifying a substring, and replace it and the characters following it with a newly computed substring

I'm working on a string manipulation code in C++ for my internship project, where I have to find a substring within a string and essentially replace it and some characters following it with a newly ...
user avatar
5 votes
0 answers
63 views

A POSIX getdelim() and getline() implementation for MSVC

Tired of always having problems in reading arbitrary length lines from file under Windows, I tried to write a POSIX getdelim() and ...
user avatar
0 votes
1 answer
28 views

OAuth implementation for Puredata

I am managing an OAuth implementation for Puredata (Pd), which is written in C. OAuth can accept RSA keys, but Pd cannot send messages with newlines, so placing private keys will come as a list of ...
user avatar
  • 155
0 votes
0 answers
47 views

Checking if the string has any characters present in a list of chars

I have this requirement to find if the input string has any restricted characters. The restricted characters are stored in a HashSet. There are totally 1351 restricted characters are present in the ...
user avatar
0 votes
2 answers
69 views

Slice function for C

I am trying to create a non-generic slice function. I want a 'view' not a copy. The scan_from arg is so that successive calls ...
user avatar
  • 503
1 vote
2 answers
78 views

Transforming a string by combining same duplicate characters

I'm solving a programming puzzle that requires to transform an input string by replacing pairs of duplicate consecutive characters with an "incremented" character, recursively, e.g. "...
user avatar
21 votes
6 answers
8k views

I created something much faster than a std::string

I've recreated std::string in a way that might be faster. System Features: Much faster than std::string. Easy to use. It was designed as part of a large database ...
user avatar
  • 351
2 votes
1 answer
64 views

Golang solution to CTCI 1.2: Check whether two strings are permutations of each other

Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...
user avatar
2 votes
1 answer
72 views

Extract regular words from string but retain all other elements and record their type

This snippet processes every regular (\w+) word in a text and reinserts the processed version: ...
user avatar
  • 1,226
1 vote
0 answers
84 views

Replacing multiple substrings in C#

There is a String.Replace method in C# and it is 1-1 mapping replacing operation, i.e. single Unicode character / string source replaced with another single Unicode ...
user avatar
  • 3,302
5 votes
1 answer
407 views

C: Reverse individual words in a string

I have been practicing C and I wanted to reverse each word in a string. I wrote this code and although it works, I am not happy with my solution. It requires twice the length of the original string to ...
user avatar
  • 329
3 votes
5 answers
422 views

Frame Strings that contain newlines

I have an application where I need to highlight some information that is printed to the console, so I wrote some static library methods which do that. I tested for bugs. Is my code clean and ...
user avatar
  • 2,006
3 votes
1 answer
36 views

MySQL procedure to extract a letter from a phrase

Create a function called GETLYRICS, which will receive as parameters a word of at most 15 letters and a number. It must return the letter of the position indicated in the number. My exercise is fine ...
user avatar
2 votes
1 answer
46 views

follow-up - Checking Nested Bracket Levels in Strings Programming Challenge

A follow-up to this question, this post improves on test case issues. To restate problem parameters, a given string S is considered closed if it: Has a matching ...
user avatar
  • 2,897
5 votes
1 answer
198 views

C smart string implementation using preprocessor

I have wrote a smart string container implementation for use in my application, but as I'am not such professional C programmer I have doubts about is I'am did it right and is there ways how to improve ...
user avatar
  • 53
4 votes
1 answer
148 views

Parse floats to a custom numeric format string

I'm working to implement a custom string format. These are the float values to convert into a string: ...
user avatar
  • 43
3 votes
1 answer
83 views

Trailing delimiter string splicing, implemented for Lua in C

I've been writing with C for a couple days, so this is a relatively advanced function compared to the simple things I've been doing previously. It's written for the Lua API, but it's still C. ...
user avatar
3 votes
3 answers
80 views

Replace string with another string in C

I have written a program that replaces a given c-string with another c-string. My code works well with small files but takes too much time while working with large files (50 Megabytes and larger). ...
user avatar
0 votes
1 answer
48 views

Time complexity of several methods of reversing a domain name string

Note: I'm aware of this existing post which is similar. However, it does not address all my questions sufficiently. I have the following three functions, all of which do the same thing: reverse a ...
user avatar
6 votes
2 answers
1k views

Entropy of String in C

I have written a C program that calculates Shannon entropy for a C-String (const char *). It works well but in many ...
user avatar
2 votes
1 answer
67 views

Longest common substring in C langauge

I have implemented the code for finding the longest common substring between two strings in C language. ...
user avatar
3 votes
1 answer
276 views

Python function to output a string that is justified to the right

I just solved this exercise from Think Python, 2nd edition: Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function ...
user avatar
1 vote
1 answer
54 views

Manacher Algorithm in Haskell

Please review the manacher algorithm in haskell. Find the longest Palindrome in a String. ...
user avatar
  • 237
13 votes
4 answers
1k views

K&R Exercise 3-3: Expand Shorthand Notations (e.g. a-d to abcd)

The following code is my answer for exercise 3-3 in K&R: ...
user avatar
0 votes
0 answers
47 views

Image file uploader webpage in HTML5 and PHP

I am trying to make a webpage for uploading image file and storing the uploaded file on server. There are several features in this implementation: There is a drag & drop zone on the webpage. You ...
user avatar
  • 3,302
3 votes
1 answer
97 views

Create VBA string array fastest method

My VBA has become really rusty but I need it for now for some data downloading. This routine works but I'm certain that over the last 10 (at least) years something quicker/less code has surfaced to do ...
user avatar
  • 131
3 votes
1 answer
135 views

get_line(): An alternative implementation of standard C library's getline() function

get_line(): An alternative implementation of standard C library's getline() function. Syntax: char *get_line(int fd, int *error_num); I know that I can declare/...
user avatar
3 votes
2 answers
129 views

Encoded string algorithm with given rules

Looking for general feedback and if there is a solution that can reduce the time complexity from the current O(n2)? Thank you. Problem Statement Consider a string that consists of lowercase English ...
user avatar
2 votes
1 answer
110 views

Related to DSA: Find longest common prefix

The objective of below code is find longest common prefix from trie DataStructure which is written in Java. Code: ...
user avatar
  • 23
3 votes
0 answers
157 views

Command line wordle

I am seeking a review of my command line wordle game. Having only recently started exploring functional programming, I expect that there will be no shortage of areas to improve. This is my first ...
user avatar
4 votes
1 answer
47 views

Awk program for extracting unique values from a k1=v1,k2=v2,... list

A single string consisting of comma-separated pairs in the format <key>=<value>, like ...
user avatar
3 votes
3 answers
183 views

Regex to extract portions of string about shipment

The Problem I'll be extracting up to 4 parts of a String that come from user-input. All 4 parts need to be in order i.e. (1-4) below in that order The first capturing group is required and the last ...
user avatar
7 votes
2 answers
556 views

Concat two strings by slicing them with same length

I want to concat two strings, by sub-stringing each one with same length, and concatenation should happen like I mentioned below for suppose, I have str1 = raines, str2 = bowls, and LENGTH as 2, then ...
user avatar
  • 71
1 vote
2 answers
89 views

Return amount of X in a string

I wrote code that returns how many of X is inside a string. The script works fine, but i was wondering if there could be any changes to improve it. ...
user avatar
0 votes
1 answer
35 views

simple string comparison program in c

I wrote this simple program to compare two strings ,I think it's working properly I just need to confirm that and also have few advices if possible ...
user avatar
2 votes
2 answers
53 views

C library implementing binary trees

This is my first attempt at writing a library in C. I have only included tree creation and in-order traversal function for now, but will expand to have more functions soon. I have three files, ...
user avatar
-1 votes
1 answer
91 views

substr() function, not present in standard C library

substr() function, not present in standard C library. Syntax: char *substr(const char *str, long start_index, long end_index); The description of function substr() ...
user avatar
4 votes
1 answer
275 views

Lingo (word-game) guessing strategy

My friend and I are kind of noobs in Python and are looking for ways to improve. We thought it would be cool if we could get some feedback on the following code. It is for a game named "Lingo&...
user avatar
3 votes
3 answers
79 views

String Reversal in C - K&R Book Exercise 1-19

I'm a Python programmer / teacher who was a CIS major in college. I'm going back to school to get my masters in CS probably, and the first course is a prerequisite Intro to Programming in C / C++. I'...
user avatar
1 vote
2 answers
116 views

Get input from stdin and discard extra characters

Syntax: char *get_input_from_stdin_and_discard_extra_characters(char *str, long size); Function get_input_from_stdin_and_discard_extra_characters() reads at most '...
user avatar
4 votes
0 answers
32 views

formatting flattened string into JSON-like object in C++, part 2

I have reworked the code from my previous (linked) post. For reference: I have a string which contains JSON-like object flattened (stringify()ed). I need to JSON-...
user avatar
2 votes
2 answers
65 views

UPDATED: str_join() function, not present in standard C library

This function str_join() is an updated version of my earlier function str_join() [Found here: https://codereview.stackexchange.com/questions/270759/str-join-function-not-present-in-standard-c-library]....
user avatar
6 votes
3 answers
655 views

Custom string-to-int converter

I have written the following function: ...
user avatar
4 votes
1 answer
233 views

tokstr, a better version of strtok/strsep/et-al

I'm a strtok_r() hater. I don't want to make a copy of my input string that it can destroy. After decades of struggle and strife I drafted a modern replacement that ...
user avatar
2 votes
1 answer
72 views

formatting flattened string into JSON-like object in C++

I have a string which contains JSON-like object flattened (stringify()ed). I need to JSON-ify it back. It's a custom format, so I wrote function to JSON-ify the ...
user avatar
1 vote
2 answers
68 views

Find longest palindrome in a string (LeetCode problem 5)

The code below is my solution to the following problem (problem #5 on LeetCode): Given a string s, return the longest palindromic substring in s. I wonder whether my use of iterators is an overkill. ...
user avatar

1
2 3 4 5
57