Tag: Character
C++ : How to split a string using String and character as Delimiter?
In this article we will see 2 techniques to split a std::string in C++ and return the result in std::vector<std::string> i.e. Splitting a std::string using a char as delimiter. Splitting a std::string using an another std::string as delimiter. How to Split a std::string using a char as delimiter: In this we will convert the passed …
C++ : How to split a string using String and character as Delimiter?Read More
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
Find frequency of each character in string and their indices | Finding duplicate characters in a string
In this article we will discuss different ways to fetch the frequency or occurrence count of each character in the string and their index positions in the string using collections.Counter() and regex. Get Frequency of each character in string using collections.Counter() collections.counter(iterable-or-mapping) Counter is a dict subclass and collections.Counter() accepts an iterable entity as argument …
Check the first or last character of a string in python
In this article, we will discuss different ways to check the content of the first or last character of a string in python. Indexing in String Every character in a string has an index number associated with it. This index can be a positive or negative number. For example, we have a string, Advertisements sample_str …
Check the first or last character of a string in pythonRead More
Python: Replace a character in a string
In this article, we will discuss different ways to replace a character in string in python. Overview: Replace all occurrences of a character in string using replace() Replace the first two occurrences of a character in string Replace a character in a string using regex Replace a character in a string using for loop Replace …
Python: Replace character in string by index position
In this article, we will discuss how to replace a character in a string at a specific position. Then we will also see how to replace multiple characters in a string by index positions. Table of Contents Use Python string slicing to replace nth character in a string Python function to replace a character in …
Python: Replace character in string by index positionRead More
Javascript: Replace all occurrences of a character in string (4 ways)
This article talks about how to replace all occurrences of a character in a javascript string using different methods and illustration through examples. Table of Contents:- Javascript replace all occurrences of a character in string using replace() Javascript replace all occurrences of a character in string using replaceAll() Javascript replace all occurrences of a character …
Javascript: Replace all occurrences of a character in string (4 ways)Read More
Javascript: Replace a character in string at given index
While working with javascript, there is often a requirement to replace a character at a particular index. This article will discuss how to replace at a specific index in a javascript string using different methods and example illustrations.Javascript does not have an in-built method to replace a particular index. Therefore, one has to create a …
Javascript: Replace a character in string at given indexRead More
Remove first character from a string in Python
In this article, we will discuss different ways to remove first characters from a string. Remove first character from string in python using slicing In python, we can slice a string to select a range of characters from it. For example, str[start:end] start and end are the index positions. The above expression returns a new …
Remove last character from a string in Python
In this article, we will discuss different ways to remove last characters from a string in python. Remove last character from string in python using slicing In python, a string can be sliced to select a range of characters from it. For example, str[start:end] Here, the start and end are the index positions. The above …