Tarun Chandra has Published 61 Articles

How to check if string or a substring of string starts with substring in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 07:44:24

972 Views

In this article, we are going to find out how to check if a string or a substring of a string starts with a substring in Python. The first approach is by using the inbuilt method startswith(). This method is used with a string, and we have to give the ... Read More

How to split at NEWLINEs in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 07:31:08

24K+ Views

In this article, we are going to find out how to split at newlines in Python. In general, split means to divide or to make a group of objects divide into smaller groups. The first approach to split at NEWLINES in python is by using the inbuilt method splitlines(). It ... Read More

How to search a string in backwards direction in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 07:05:30

3K+ Views

In this article, we are going to find out how to search a string in backward direction in Python. The first method is to use the inbuilt python String class's rindex() method. The highest index of any substring in the given string is returned by the Python string rindex() method. ... Read More

How to check if text is “empty” (spaces, tabs, newlines) in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 06:57:59

2K+ Views

In this article, we are going to focus on how to check if the text is empty (spaces tabs newlines) in Python. The first method is to use the built-in string library's isspace() method. The isspace() method determines whether a string contains only spaces or contains any other characters. If ... Read More

How to check if a unicode string contains only numeric characters in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 06:53:32

614 Views

In this article, we are going to find out how to check if a Unicode string contains only numeric characters in Python. We will use the inbuilt function isnumeric() to check if there are only numeric characters present in a string. It is similar to isdigit() and isdecimal() but it ... Read More

How to check if a string only contains certain characters in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 06:50:45

6K+ Views

In this article, we are going to find out how to check if a string contains only certain characters in Python. The first approach is by using sets. We will declare a set with all the characters that are acceptable and we will check if the input string is a ... Read More

What is the Python regular expression to check if a string is alphanumeric?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 06:46:23

5K+ Views

In this article, we are going to focus on how to check if a string is alphanumeric using Regular expressions in Python. Regular expressions are used in both the techniques. Import the re library and install it if it isn't already installed to use it. After importing the re library, ... Read More

How do I verify that a string only contains letters, numbers, underscores and dashes in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 06:41:59

11K+ Views

In this article, we are going to find out how to verify a string that contains only letters, numbers, underscores, and dashes in Python. The first strategy makes use of regular expressions. To use the re library, import it and install it if it isn't already installed. We use the ... Read More

How to check if a string has at least one letter and one number in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 06:35:10

4K+ Views

In this article, we are going to find out how to check if a string has at least one letter and one number in Python. Regular expressions is used in the first technique. Import the re library and install it if it isn't already installed to use it. After importing ... Read More

How can I test if a string starts with a capital letter using Python?

Tarun Chandra

Tarun Chandra

Updated on 26-Oct-2022 08:12:36

12K+ Views

A string is a collection of characters that can represent a single word or a whole sentence. Unlike Java there is no need to declare Python strings explicitly we can directly assign string value to a literal. A string in Python is represented by a string class which provides several ... Read More

Advertisements