![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 27104 Articles for Server Side Programming
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
377 Views
* An asterisk meta-character in a regular expression indicates 0 or more occurrences of the pattern to its leftThe following code matches and prints the zero or more occurrences of the pattern '\w' in the string 'chihua huahua'Exampleimport re s = 'chihua huahua' result = re.findall(r'\w*', s) print resultOutputThis gives the output['chihua', '', 'huahua', '']
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
65 Views
The following code replaces all the characters from given string with ''Exampleimport re line = 'this is a text with in between and then there are instances ... where the number ranges from 0-99.\ and there are many other lines in the text files \ with such tags ' line = re.sub(r"", "", line) print lineOutputThis gives the outputthis is a text with in between and then there are instances ... where the number ranges from 0-99.and there are many other lines in the text files with such tags
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
452 Views
The word boundary \b matches positions where one side is a word character (usually a letter, digit or underscore)\B matches all positions where \b doesn't match.The following code shows how regexpr \B worksimport re result = re.findall(r'\Bcat', 'certificate') result2 = re.findall(r'\Bcat', 'tomcat') result3 = re.findall(r'\Bcat', 'catfish') print result, result2,result3This gives the output['cat'] ['cat'] []
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
3K+ Views
When you use match and search methods of module re, if there is a match, it has bool value of True and if there is no match, you get None that has a bool value of False.Match objects are always true, and None is returned if there is no match>>> bool(re.search("def", "abcdefgh")) True >>> bool(re.search("rest", "pqrstuv")) False
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
2K+ Views
Regular expressions are an essential tool for searching and manipulating strings in Python. Among the various patterns and techniques available, the [d+] expression is particularly useful for matching one or more digits in a string. In this article, we will explore the [d+] regular expression pattern, its usage, and provide five code examples with step−by−step explanations to help you understand and apply this concept in your Python projects. Before diving into the code examples, let's first understand the [d+] pattern. [d+] is a combination of two elements: [d]: This is a shorthand character class for the digits 0 to 9. ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
10K+ Views
We can pass re.IGNORECASE to the flags parameter of search, match, or sub −Example import re print (re.search('bush', 'BuSh', re.IGNORECASE)) print (re.match('bush', 'BuSh', re.IGNORECASE)) print (re.sub('bush', 'xxxx', 'Bushmeat', flags=re.IGNORECASE))Output xxxxmeat
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
10K+ 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 get to know how to extract decimal numbers from a string in python using regular expressions. We use \d+\.\d+ regular expression in python to get non digit characters from a string. Where, \d returns a match where ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
56K+ Views
In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In this article, we will show you how to check if the given input list is an empty list or NOT using python. Below are the 5 methods to accomplish this task − Using not operator Using len() function By Comparing with an Empty List Using __len__() Using NumPy Module Assume we have taken an empty list. We will check if the input list is empty or not and returns some random message for acknowledgment using different methods ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
247 Views
A nested list is a list which has elements as lists itself. For example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] is a nested list as it has 3 lists ([1, 2, 3], [4, 5, 6], and [7, 8, 9]) as its elements. To flatten a list of lists (nested list) i.e., to convert a 2D list into a 1D list, there are different ways such as nested for loop, list comprehension, built-in functions or by importing libraries in python. In this article we will discuss the above methods to flatten a list in Python. Using for loops ... Read More