
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

331 Views
In Python tuples are an important data structure that allows you to group many values together. But some beginners may find it confusing to use tuples inside functions. This article will explain what tuples are and how to use them properly in functions. We will also discuss some real-world examples, from basic to complex, to help you understand. A tuple is an ordered, unchangeable collection of datatypes in Python. It means that after a tuple has been created, its values cannot be changed. Tuples are defined with parentheses "()". Example of a Tuple Here is a simple example of how ... Read More

2K+ Views
When working with text data in Python, we normally need to interact with strings to make them readable or properly formatted. It is very common way to use regular expressions or regex to add spaces before and after a particular character. In this article we will see how to do this by using Python's re module.Adding Space at a Character Using regex Regular expressions are a powerful way to search for and modify strings based on patterns. There are multiple uses for regex that are made possible by Python's re package. Spaces between characters can improve the readability and the ... Read More

1K+ Views
Regular expressions are a very crucial part of Python's built-in 're' module. It is used to work with text data. One of the advantages of regex is the ability to use alternatives, which allows you to match one pattern out of multiple options. Alternatives in the regular expressions function are just like "or" statements. They help you to define many patterns to match against a given string. The vertical bar | denotes the "or" operator in regex. For example, the regex pattern PHP|Python will match either "PHP" or "Python" in a given string. The following are the 4 different ways ... Read More

800 Views
To extract decimal numbers from a string in Python, regular expressions are used. A regular expression is a group of characters that allows you to use a search pattern to find a string or a set of strings. RegEx is another name for regular expressions. The re module in Python is used to work with regular expressions. In this article, we will learn how to extract decimal numbers from a string in Python using regular expressions. We use the following regular expression in Python to get non-digit characters from a string - \d+\.\d+ Where, ... Read More

852 Views
Backreferences in regular expressions allow us to reuse a previously recorded group inside the same regex pattern. This ability is very useful when we want to match recurrent patterns in strings. What are Backreferences? A regular expression reference to a previously recorded group is called a backreference. When parentheses "()" are used in a regex pattern, a group is formed. Each group is assigned a number; the number for the first group is 1. We can refer to these recorded groups in our regex by using the backslash \ after the group number. Basic Syntax Here is the basic ... Read More

11K+ Views
In Python, we can use regular expressions when looking for patterns in text. So we have a useful method called groups() in Python. This method helps us to find and manage many parts of a pattern. So in this article will explain how the groups() method works. The groups() Method The match.group() function in Python's re module is used to get the captured groups after a successful regular expression match. When a regular expression uses parentheses, it creates capturing groups with the matched substrings. The match.group() method returns the captured substrings. The following is the syntax of the groups() method ... Read More

2K+ Views
We can build regular expressions that recognize repeated character groups using a few special characters. The following metacharacters can be used to search for a character or set of repeated characters. The question mark was the first repeating operator or quantifier developed. It effectively makes it optional by instructing the engine to try matching the previous token 0 or 1 times. Matching Simple HTML Tags Using Regular Expressions The engine is instructed to try matching the previous token zero or more times by the asterisk or star. The plus instructs the engine to make one or more attempts to match ... Read More

401 Views
Regular expression, or regex, is a useful tool in Python that helps identifying and processing of text patterns. It helps you cut, edit and check text in different ways. In this article, we will talk about how not to match a character after repetition in regex and look at five different examples. We will provide you a clear explanation to help you understand how each one works. All of the examples we will create in this article, we will use the re.findall() method, which is a built-in method of Python's re module. Let us know about this function first - ... Read More

2K+ Views
A single character can be matched in Python using a regular expression. A regular expression is a sequence of characters that helps you find a string or a set of strings using a search pattern. Regular expressions are also known as RegEx. Python provides the re module that is used to work with regular expressions - Using findall() function We use findall() searches for the strings matching the specified pattern in the given string and return all the matches in the form of a list of strings or tuples. Example 1 In the following example, we begin by importing the regular ... Read More

6K+ Views
A regular expression is a group of characters that allows you to use a search pattern to find a string or a set of strings. RegEx is another name for regular expressions. The re module in Python is used to work with regular expressions. In this article, we learn how to extract non-digit characters in Python using regular expressions. We use \D+ regular expression in Python to get non-digit characters from a string. Where, \D returns a match that does not contain digits. + implies zero or more occurrences of characters. ... Read More