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

2K+ Views
In this article, we are going to learn how to extract a URL from an HTML link using Python regular expressions. URL is an acronym for Uniform Resource Locator; it is used to identify the location resource on the Internet. URL consists of a domain name, path, port number, etc. The URL can be parsed and processed by using a Regular Expression. Therefore, if we want to use a Regular Expression, we have to use the "re" library in Python. Following is an example of a URL - URL: https://www.tutorialspoint.com/courses If we parse the above URL we can find ... Read More

3K+ Views
In this article, you will find out how to use the range in Python regular expressions. With the help of Python's regular expressions, you can search, match, and manipulate text efficiently. One useful feature in regex is ranges, so it helps us define sets of characters within square brackets "[ ]". Range in Regex In Python, a range is used when you want to match characters within a specific group. It is defined inside brackets "[ ]" with the help of a hyphen -. For example: # Matches any digit (0 to 9) pat1 = r"[0-9]" ... Read More

724 Views
In this article you will find to write regular expression in Python to find repeating digits in the given number. Regular expression is a special feature that helps you find matching parts of a string. It can find all repeated characters or digits in a number. Finding repeating digits can help in many areas like data analysis or validation. For example, check if a number like 1223 has repeated digits "2" or "3". So in this example 2 is the repeated digit. Let us see how you can perform this task practically using Python Regex. Regex Pattern for Repeated Digits ... Read More

1K+ Views
This article gives a guide on how to capture an exception raised by a regular expression in Python. We will also see simple example programs that show how to do this. Regular expressions are useful for matching patterns in text, but they may result in errors like incorrect syntax or mismatches. Python uses exception handling (try-except) to handle these errors to avoid errors. For example, if the given pattern is "[a-z", which is an incorrect pattern that can lead to an error showing that the character set is invalid, because the closing bracket ] is missing. Python Regex Exception ... Read More

723 Views
This article talks about how you can clear the regular expression cache in Python. Regular expressions in Python are used to find patterns in text, but they also use an internal cache to store frequently used expressions for faster execution. We may sometimes need to clear this cache to free up memory or reset stored patterns. You can do this using Python's re.purge() method. Why Clear Regex Cache? You need to clear the regex cache for the following reasons - Too many stored patterns may consume your system's memory. If you are dynamically updating regex patterns, deleting the cache ... Read More

86 Views
This article explains how to work with Regular Expressions (RegEx) in Python using the "re" module. RegEx is a sequence of characters that defines a search pattern. Below are different ways to use RegEx in Python. These are some of the essential methods in Python's re module that help with pattern matching, searching, replacing, and extracting data efficiently. Using the re.match() method Using the re.findall() method Using the re.search() method Using the re.sub() and re.subn() methods Using the re.split() method Using re.match() Method The re.match() method checks if a string matches a given pattern at the ... Read More

328 Views
This article will discuss how to compare regular expressions in Perl and Python. Regular expressions, or regex, are patterns used to match strings. Both Perl and Python support regex, but they have some differences in syntax and usage. For example, you write a regular expression like this in Perl - $text =~ /pattern/ But you write it like this in Python - re.search('pattern', text) So in the below section of this article will show the similarities and differences between Perl and Python regex with simple examples - ... Read More

415 Views
This article will discuss the difference between dot '.', question mark '?', and asterisk'*' in Python regular expressions. In regular expressions, '.' means any one character except the newline, '*' means zero or more times of the character or group before it. and '?' means zero or one time of the character or group before it. In some types of regex, ? Also makes things non-greedy. As we have seen in Python regular expressions, these symbols have different meanings, so let us understand these symbols using the examples - Usage of Dot (.) The following example will use ... Read More

2K+ Views
This article will discuss how to escape all the special characters for regular expressions in Python. So when you work with regular expressions in Python, some characters have special meanings like *, ., +, ?, (, ), etc. These characters are special characters in regular expressions. If you want to look for them as plain text, you can escape them. Python provides a special function to do this task, which is the re.escape() function. The re.escape() function automatically adds a backslash \ before each special character in the given string. By using it, we can make the string safe to ... Read More

3K+ Views
Python provides a regular expression-specific built-in library named "re". You only need to import it to use its features (such as search, match, findall, etc.). They'll provide you back a Match object with helpful techniques for modifying your outcomes. According to Wikipedia, regular expressions (also known as regexp) are collections of characters that specify a search pattern. It is a tool that enables you to filter, extract, or alter a series of characters. It has also been discovered that regular expressions function more quickly when the "in" operator is used. Regular expressions have performance difficulties and are generally difficult to debug and maintain. ... Read More