
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 10451 Articles for Python

724 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

769 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

1K+ 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

364 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

1K+ 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

1K+ Views
There are two ways to match any one uppercase character in python using Regular Expression. One is the general method and other is using the regular expression. A regular expression is a series of characters that allows you to discover a string or a set of strings using a search pattern. Regular expressions are sometimes known as RegEx. In Python, the re module is used to work with regular expressions. How to Match an Uppercase Character? In this article we will match the uppercase vowel in Python using a regular expression. To do this we will use r'[A, E, I, ... Read More

855 Views
In this article, you will learn how to match any single lowercase vowel (a, e, i, o, u) using Python regular expressions (regex). We will understand how to use Python's re module to apply a pattern that finds these vowels in a string. Ways to Match Lowercase There are two ways to match any one lowercase vowel in Python using a Regular Expression. One is using the if loop, and the other is using a regular expression. Using the General Method ... Read More

1K+ Views
A regular expression is a series of characters that allows you to discover a string or a set of strings using a search pattern. Regular expressions are sometimes known as RegEx. In Python, the re module is used to work with regular expressions. We can use repetitions in regular expression to match the string in python. To make repetitions possible in regular expression, we indicate the number of times the character is repeated in {}. Understanding Repetitions in Regex Regex allows you to specify the number of times a pattern should appear by using various special characters. The definitions of ... Read More