Blog

python tutorials and learn python

Created with Sketch.

Python Regex Cheat Sheet

Python Regex Cheat Sheet This page provides a Python regex cheat sheet that you can quickly reference while working with regular expressions. Character sets Pattern Meaning \w Match a single word character a-z, A-Z, 0-9, and underscore (_) \d Match a single digit 0-9 \s Match whitespace including \t, \n, and \r and space character…
Read more

Python Regex Flags

Python Regex Flags Summary: in this tutorial, you’ll learn about the Python regex flags and how they change the behavior of the regex engine for pattern matching. Introduction to the Python regex flags The regular expression functions like findall, finditer, search, match, split, sub, … have the parameter (flags) that accepts one or more regex…
Read more

Python Regex split()

Python Regex split() Summary: in this tutorial, you’ll learn how to use the Python regex split() function to split a string at the occurrences of matches of a regular expression. Introduction to the Python regex split() function The built-in re module provides you with the split() function that splits a string by the matches of…
Read more

Python Regex sub()

Python Regex sub() Summary: in this tutorial, you’ll learn about the Python regex sub() function that returns a string after replacing the matched pattern in a string with a replacement. Introduction to the Python regex sub-function The sub() is a function in the built-in re module that handles regular expressions. The sub() function has the…
Read more

Python Regex search()

Python Regex search() Summary: in this tutorial, you’ll learn how to use the Python regex search() function to return the first match of a pattern in a string. Introduction to the Python regex search() function The regex search() is a function in the built-in re module that deals with regular expressions. The search() function has…
Read more

Python Regex match()

Python Regex match()   Summary: in this tutorial, you’ll learn how to use the Python regex match() function to find a match with a pattern at the beginning of a string. Introduction to the Python regex match function The re module has the match() function that allows you to search for a pattern at the…
Read more

Python Regex finditer()

Python Regex finditer()   Summary: in this tutorial, you’ll learn how to use the Python regex finditer() function to find all matches in a string and return an iterator that yields match objects. Introduction to the Python regex finditer function The finditer() function matches a pattern in a string and returns an iterator that yields…
Read more

Python Regex fullmatch()

Python Regex fullmatch() Summary: in this tutorial, you’ll learn how to use the Python regex fullmatch() to match the whole string with a regular expression. Introduction to the Python regex fullmatch function The fullmatch() function returns a Match object if the whole string matches the search pattern of a regular expression, or None otherwise. The…
Read more

Python Regex findall()

Python Regex findall() Summary: in this tutorial, you’ll learn how to use the Python regex findall() function to find all matches of a pattern in a string. Introduction to the Python regex findall() function The findall() is a built-in function in the re module that handles regular expressions. The findall() function has the following syntax:…
Read more

Python Regex Lookbehind

Python Regex Lookbehind Summary: in this tutorial, you’ll learn about Python regex lookbehind and negative lookbehind. Introduction to the Python regex lookbehind In regular expressions, the lookbehind matches an element if there is another specific element before it. The lookbehind has the following syntax: (?<=Y)X   In this syntax, the pattern will match X if…
Read more