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
1 answer
80 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
304 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
69 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
57 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,576
3 votes
1 answer
115 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
162 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
173 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
118 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
189 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
61 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
190 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
566 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
93 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
37 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
63 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
109 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
361 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
86 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
210 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
37 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
69 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
668 views

Custom string-to-int converter

I have written the following function: ...
user avatar
4 votes
1 answer
239 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
79 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
83 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
7 votes
2 answers
698 views

C code to convert hexadecimal string to base64

I've written a program to convert a hex-encoded string to base64, and here is my code. My main concerns are: Optimizations - Is my code sufficiently optimized and if any more optimization is possible....
user avatar
2 votes
1 answer
69 views

Any issue with this as a password generator?

Was trying to create a password generator like the one Bitwarden has... Curious if anyone sees any issues with this? (wordlist shortened for readability) There perhaps there's a more efficient way I'...
user avatar
5 votes
2 answers
130 views

str_split() function, not present in standard C library

Below is the code for a str_split() function; this function is not present in standard C library. Syntax: ...
user avatar
1 vote
1 answer
208 views

Better ways to parse the Content-Length from the HTTP header

I have a buffer that contains the HTTP header, which contains the Content-Length string indicating how big the file is that needs to be downloaded. I am looking to ...
user avatar
  • 284
2 votes
2 answers
100 views

Replace Western Arabic numerals with Persian digits

I've written and used this code in my apps whenever needed to convert any Western Arabic numerals into Eastern Arabic (or better say, Persian/Farsi) numerals in any Persian text. It works fine as ...
user avatar
  • 121
6 votes
5 answers
1k views

TString - An implementation of std::string

I wanted to make a feature rich string in C++. Similar to one in python. I am using C++14. I have not added much yet, I just want to get my code reviewed to ensure I am going the right way. Features: ...
user avatar
-1 votes
2 answers
120 views

New String similarity algorithm (java)

Recently I have been developing a library for Java which provides utility functions for arrays, strings, etc.. While researching string similarity algorithms, I managed to write one of my own. I am ...
user avatar
  • 39
0 votes
0 answers
21 views

make an array of cells from formula like in excel with javascript?

I'm working on stylesheet in Excel, and I've made this function of makeCells is there a better way of doing it. I've tried regex to get two cells ...
user avatar
0 votes
1 answer
70 views

2 ConvertToBase3 methods with great disparity of execution time

I have two methods to do the same thing: convert a number to ternary. ...
user avatar
  • 109
1 vote
0 answers
114 views

Java reimplementation of the Python difflib.SequenceMatcher class

I'm rewriting a Python script into an Android app. This script uses difflib.SequenceMatcher to compare sequence of strings. I haven't been able to find something ...
user avatar
  • 235
1 vote
1 answer
90 views

Conversion from string to long double

This is a follow up to https://codereview.stackexchange.com/questions/272333/conversion-from-long-double-to-string where I do the reverse conversion. This time around it is string to long double. It ...
user avatar
4 votes
0 answers
44 views

Diagonal square spiral pattern in Vyxal

I wrote this code as a reference implementation for this challenge. How can I make it more readable and/or efficient? The goal is to take an integer and create patterns like the following: ...
user avatar
6 votes
5 answers
591 views

Word transformation

I have started to practice programming by doing exercises and I want to get feed back to improve my self in nice clean coding and I found this website. The program I wrote now is a word transformation ...
user avatar
3 votes
2 answers
297 views

Parsing a std::string to a dictionary (std::map)

As always - the context ! Preliminaries Recently I needed a way to transport data from one environment to another. Though the proper way (probably) to do this would be to use databases (which I don't ...
user avatar
  • 771
2 votes
2 answers
109 views

finding whether two string are anagrams of each other [closed]

...
user avatar
3 votes
2 answers
271 views

str_join() function, not present in the standard C library

This function str_join() is an updated version of my earlier function strcat_new() — found here: ...
user avatar
1 vote
1 answer
108 views

get address parts based on requested parts

I have different format of address in an array, those format looks like this ...
user avatar
  • 111
-2 votes
1 answer
221 views

Fastest string search algorithm invented by me. It is called ""Choudhary String Search Algorithm""

I have invented the fastest string search algorithm. It is called ""Choudhary String Search Algorithm (choudharyStringSearchAlgorithm)"". I have compared my algorithm with Brute ...
user avatar
4 votes
3 answers
353 views

Functions in C language that manipulate strings, not present in the standard C library

I have implemented few functions in C language that manipulate strings. These functions are not present in the standard C library. string_library.c ...
user avatar
3 votes
2 answers
455 views

Simple string manipulation in C (for small microcontrollers)

Although I have long experience of other languages, I've not used C until playing around with microcontrollers using the Arduino IDE. I'm a bit uncomfortable with my use of pointers in conjunction ...
user avatar
2 votes
2 answers
76 views

Function to find substring in a list of strings and add them to the resulting list

I am trying to look for a substring in a list of strings. My end result is an array that contains the presence of substring first based on course.name and then ...
user avatar
3 votes
2 answers
62 views

User-friendly string struct and utility function - upated version

Updated previously posted string struct and utility functions Previous link: User-friendly string struct and utility functions What is updated ? typedef of sstring is a major update. previously, ...
user avatar
  • 77
1 vote
2 answers
41 views

Function to remove set of trailing characters from string

I needed the ability to truncate the trailing end of path strings in a routine that builds new search paths as it recursively searches directories. After not finding what I was looking for I created ...
user avatar
  • 328
3 votes
2 answers
308 views

string increment

Last night I was practicing incrementing strings. What it needs to do is increment the last character if it is a digit or letter. Special characters are ignored. The code that I have written does the ...
user avatar

1
2
3 4 5
58