Tag: Substring
Javascript: Check if string contains substring
This article will see how to check if a substring is present in a string through different methods and various examples. Table of Contents:- Javascript check if string contains substring using includes() Javascript check if string contains substring using indexOf() Javascript check if string contains substring using includes() Javascript includes() method is used to perform a case-sensitive …
Javascript: Remove substring from start of a string
We often come across a requirement to remove a substring from the start of a string to process it. For example, remove Mr or Mrs from names. This article will illustrate simple ways to remove a prefix from a string using different methods and examples. Table of Contents:- Remove substring from start of a string …
Javascript: Remove substring from start of a stringRead More
Javascript: Remove substring from end of a string
We often come across a requirement to remove a substring from the end of a string to process it. This article will illustrate simple ways to remove a substring from the end of a string using different methods and examples. Table of Contents:- Remove substring from end of a string in javascript using replace() Remove …
Difference between slice() and substring() in javascript
The two popular methods of javascript strings slice() and substring() are very similar, but there are a few differences. This article discusses the differences between the slice() and substring() methods using various scenarios and example illustrations. Let’s start looking into the syntax of both: syntax of slice():- slice(startIndex, endIndex) Here, Advertisements The indexes of the slice() method are …
Difference between slice() and substring() in javascriptRead More
Javascript: substring() method
This article discusses the syntax and functioning of the substring() method in javascript including various examples for illustration purposes. Usage of substring():- Javascript’s substring() method returns a string portion between the start and end indexes or to the end of the string if the endIndex is not present. Syntax of substring():- substring(startIndex, endIndex) Here, Advertisements …
Replace all occurrences of a substring in string – Python
In this article, we will discuss different ways to replace all occurrences of a given substring in a string in Python. Suppose we have a string, “This is the last rain of Season and Jack is here.” After replacing all occurrences of “is” with with the “XX”, the final string should be like, Advertisements “ThXX …
Replace all occurrences of a substring in string – PythonRead More
Replace first occurrence of a substring in Python
In this article, we will discuss different ways to replace the first occurrence of a substring from a string in Python. Suppose we have a string, “This is the last rain of Season and Jack is here.” In this string, the substring “is” occurs at 3 different places. But we want to replace only the …
Extract substring between two markers in Python
In this article, we will learn to extract a substring between two markers in a string using Python Programming Language. But before that we should know what is a substring in Python programming language? A substring is a sequence of characters which is a part of a string often created using methods like slicing or …
Check if a substring is in list of strings in Python
In this python tutorial, you will learn how to check if a substring is in a list of strings. Table Of Contents Check if a substring is in a list of strings using any() Check if a substring is in a list of strings using join() Check if a substring is in a list of …
Check if a substring is in list of strings in PythonRead More
How to Get a SubString from a String in Python?
In this python tutorial, you will learn how to get a substring from a string. Table Of Contents Introduction Get a substring from a string by index position Get substring from a string through slicing Get substring containing first character only Get substring containing last character only Get a substring from a string using the …