Nikitasha Shrivastava

Nikitasha Shrivastava

52 Articles Published

Articles by Nikitasha Shrivastava

Page 5 of 6

How regular expression back references works in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 1K+ Views

Backreferences in regular expressions allow us to reuse a previously captured group within the same regex pattern. This feature is extremely useful for matching repeated patterns, validating formats, and finding duplicates in strings. What are Backreferences? A backreference is a reference to a previously captured group in a regular expression. When parentheses "()" are used in a regex pattern, they create a capturing group. Each group is automatically assigned a number starting from 1 for the first group, 2 for the second, and so on. Syntax Here's the basic syntax for using backreferences ? ...

Read More

How not to match a character after repetition in Python Regex?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 535 Views

Regular expressions (regex) are powerful tools in Python for pattern matching and text processing. Sometimes you need to match a pattern but exclude cases where specific characters follow after repetition. This is achieved using lookahead assertions that check what comes next without including it in the match. Understanding re.findall() Function The re.findall() function searches for all occurrences of a pattern in a string and returns them as a list. It takes two main parameters: the pattern to search for and the string to search in. Syntax import re re.findall(pattern, string) Using Positive ...

Read More

How to match a single character in python using Regular Expression?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 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. The Dot (.) Metacharacter The dot . is a special metacharacter in regular expressions that matches any single character except newline. It's the most common way to match a single character in a pattern. Using findall() Function The findall() function searches ...

Read More

How to match any one uppercase character in python using Regular Expression?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 2K+ Views

A regular expression (regex) is a pattern-matching tool that helps find specific characters or patterns in strings. In Python, the re module provides regex functionality. To match uppercase characters, you can use character classes like [A-Z] or specific character sets. Basic Regex Pattern for Uppercase Characters The pattern [A-Z] matches any single uppercase letter from A to Z. For specific uppercase characters like vowels, use [AEIOU]. import re string = 'TutoriAls PoInt Is A Great PlatfOrm to LEarn' uppercase_vowels = re.findall(r'[AEIOU]', string) print("Uppercase vowels found:", uppercase_vowels) Uppercase vowels found: ['A', 'I', 'I', ...

Read More

How to match any one lowercase vowel in python using Regular Expression?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 2K+ Views

In this article, you will learn how to match any single lowercase vowel (a, e, i, o, u) using Python regular expressions. We will explore different approaches using Python's re module to find and manipulate vowels in strings. Approaches to Match Lowercase Vowels There are two main ways to match any lowercase vowel in Python: Using the General Method Using Regular Expressions ...

Read More

How to specify repetitions Regex in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 2K+ Views

A regular expression is a series of characters that allows you to match strings using search patterns. In Python, the re module is used to work with regular expressions. Repetition quantifiers in regex specify how many times a character or pattern should appear. Python regex supports several repetition operators that make pattern matching flexible and powerful. Types of Repetition Quantifiers Regex provides several special characters to specify repetitions − Asterisk (*): Matches zero or more occurrences of the preceding element. ...

Read More

How to match pattern over multiple lines in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 15K+ Views

Learning Python's Regular Expressions (Regex) may require you to match text that spans multiple lines. This commonly occurs when reading information from files or scraping data from websites. This article demonstrates how to match patterns across multiple lines using Python's re module with special flags like re.DOTALL and re.MULTILINE. Understanding Multi-line Pattern Matching By default, the dot metacharacter . in regular expressions matches any character except newline characters. To match patterns that span multiple lines, Python's re module provides special flags that modify this behavior ? re.DOTALL: Makes . match any ...

Read More

How to get first 100 characters of the string in Python?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 6K+ Views

As you may know a string is a group of letters, numbers, or symbols in Python. Sometimes we do not need the whole string. We may only want a small part of it. For example, we may want only the first 100 characters. Python makes this easy by using something called slicing. Slicing means taking a part of the string using square brackets [] with numbers inside to specify the range. In this article, we will show you how to get the first 100 characters of a string in Python. The following are the 4 different methods to accomplish ...

Read More

How do we create Python String from list?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 24-Mar-2026 339 Views

In programming, it is very common to work with lists, which are collections of items. Sometimes, you may want to turn a list into a single string. In this chapter, we will show you how to create a Python string from a list using simple explanations and examples. Understanding Lists A list in Python is a way to store multiple values. For example, you can have a list of words like ? my_list = ["Hello", "world", "Python", "is", "great"] print(my_list) ['Hello', 'world', 'Python', 'is', 'great'] In this example, we have a ...

Read More

How to use Python Regular expression to extract URL from an HTML link?

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 16-Mar-2026 3K+ Views

In this article, we will learn how to extract URLs from HTML links using Python regular expressions. A URL (Uniform Resource Locator) identifies the location of a resource on the Internet, consisting of components like protocol, domain name, path, and port number. Python's re module provides powerful regular expression capabilities for parsing and extracting URLs from HTML content. Regular expressions allow us to define search patterns that can identify and extract specific URL formats from text. Regular Expressions in Python A regular expression is a search pattern used to find matching strings in text. Python's re module ...

Read More
Showing 41–50 of 52 articles
Advertisements