Tag: Strings
How to trim strings in C++ using Boost String Algorithm Library
In this tutorial we will discuss how to use trim algorithms from C++ Boost String Algorithm Library. Let’s learn them step by step, Boost String algorithm library provides different algorithms for string trimmings. Let’s first discuss the simple one i.e, What if we want to trim the string of white spaces from left side or …
How to trim strings in C++ using Boost String Algorithm LibraryRead More
Python : How to Sort a list of strings ? | list.sort() Tutorial & Examples
In this article we will discuss how to sort a list of string by, By Alphabetical Order By Reverse Alphabetical Order By String Length By Numeric Order list.sort() list provides a member function sort(). It Sorts the elements of list in low to high order i.e. if list is of numbers then by default they will …
Python : How to Sort a list of strings ? | list.sort() Tutorial & ExamplesRead More
C++ : strcmp() Tutorial | Comparing strings
In this article we will discuss how to compare strings using strcmp(). strcmp() is a C Library function that helps to compare two strings i.e. char * Advertisements int strcmp ( const char * firstStr, const char * secondStr ); It iterates over both strings i.e. firstStr & secondStr in parallel and compares each character …
Python : How to pad strings with zero, space or some other character ?
In this article we will discuss how to do left padding of strings or right padding of strings either with zero, space or some other character. Left padding of string in Python Left padding a string means adding a given character at the left side of string to make it of a given length. Let’s …
Python : How to pad strings with zero, space or some other character ?Read More
Python : How to Compare Strings ? | Ignore case | regex | is vs == operator
In this article we will discuss different ways to compare strings in python like, using == operator (with or without ignoring case) or using is operator or using regex. Python provides various operators to compare strings i.e. +, !=, <, >, <=, >=. When used for comparison these operators return Boolean True or False value. …
Python : How to Compare Strings ? | Ignore case | regex | is vs == operatorRead More
Python: Search strings in a file and get line numbers of lines containing the string
In this article, we are going to discuss, how to search for single or multiple strings in a file and get all the matched lines along with their line numbers. Check if a string exists in a file To check if a given string exists in the file or not, we have created a function, …
Python: Search strings in a file and get line numbers of lines containing the stringRead More
Python: Remove a character from a list of strings
In this article, we will discuss different ways to remove a character from a list of strings in python. Suppose we have a list of strings, list_of_str = [‘what’, ‘why’, ‘now’, ‘where’, ‘who’, ‘how’, ‘wow’] Now, we want to remove all occurrences of character ‘w’ rom this list of strings. After that list should be …
Sort an Array of Strings Alphabetically in Javascript
Very common requirement developers encounter while working with javascript arrays is to sort an array of strings. This article demonstrates easy ways to sort array of strings alphabetically in ascending as well as descending order using various example illustrations. Table of Contents: Sort an array of strings using sort() method Sort an array of strings …
Sort an Array of Strings Alphabetically in JavascriptRead More
Javascript: Sort Array of Strings by Length
We often use sorting while working with arrays. This article demonstrates easy ways to sort an array of strings by their length using different methods and various example illustrations. The strings within the array will be sorted based on their length. A string with the lowest length will be placed first in the array, followed …
Check if strings are equal in C++
This article will discuss different ways to check if two strings are equal in C++. Table Of Contents Check if strings are equal using == operator Check if strings are equal using compare() function Check if strings are equal using the equal() function Check if strings (char *) are equal using strcmp() Check if strings …