Blog

python tutorials and learn python

Created with Sketch.

Regex Alternation

Regex Alternation Summary: in this tutorial, you’ll learn about regex alternation, which is simply an “OR” operator in the regular expression. Introduction to the regex alternation Regular expressions use the pipe character (|) to denote an alternation. The alternation is simple the OR operator in the regular expressions. For example, the following pattern uses the…
Read more

Regex Backreferences

Regex Backreferences Summary: in this tutorial, you’ll learn how to use the regex backreferences and their practical applications. Introduction to Regex Backreferences When constructing a regular expression, you can put \n within the pattern. In this case, the \n is a backreference of a capturing group number n. Regex Backreference examples Let’s take some examples…
Read more

Regex Capturing Groups

Regex Capturing Groups Summary: in this tutorial, you will learn how to use the regex capturing groups to group and capture parts of a match. Introduction to the regex capturing groups Suppose you have a URI with the following format: ‘posts/25’ Code language: PHP (php) The URI has a resource name (posts) and id (25).…
Read more

Regex Non-greedy (or Lazy)

Regex Non-greedy (or Lazy) Summary: in this tutorial, you’ll learn about the regex non-greedy (or lazy) quantifiers that match their preceding elements as few times as possible. Introduction to the regex non-greedy (or lazy) quantifiers In regular expressions, the quantifiers have two versions: greedy and non-greedy (or lazy). In the previous tutorial, you learned how…
Read more

Regex Greedy

Regex Greedy Summary: in this tutorial, you’ll learn about the regex greedy mode and how it affects the way the quantifiers search for matches. The problem with the regex greedy mode Suppose you have the following string: <a href=”/” title=”Go to homepage”>Home</a> Code language: PHP (php) And you want to match the text within the…
Read more

Regex Quantifiers

Regex Quantifiers Summary: in this tutorial, you’ll learn how to use quantifiers in regular expressions to match a number of instances of a character or a character class. Introduction to regex quantifiers Quantifiers allow you to match their preceding elements a number of times. The following table shows the list of quantifiers: Quantifier Meaning *…
Read more

Regex Sets and Ranges

Regex Sets and Ranges Summary: in this tutorial, you’ll learn about the regex sets and ranges to create regular expressions that match a set of characters. Sets A set is one or more characters specified in square brackets. For example: [abc] Code language: PHP (php) Since a set matches any characters in the square brackets,…
Read more

Regex Word Boundary

Regex Word Boundary Summary: in this tutorial, you’ll learn to use the regex word boundary to match the word boundary position in a string. Introduction to the regex word boundary The word boundary anchor \b matches a position called a word boundary in a string. A word boundary’s position can be one of the following:…
Read more

Regex Anchors

Regex Anchors Summary: in this tutorial, you’ll learn how to use the regex anchors to match the start and the end of a string. Introduction to the regex anchors Unlike character classes, the regex anchors do not match characters, but a position before or after characters: ^ : The caret anchor (^) matches the beginning…
Read more

Regex Character Classes

Regex Character Classes Summary: in this tutorial, you’ll learn about the regex character classes and how to create regular expressions with patterns that match a set of characters. A character class is a set of characters, for example, alphabets, numbers, whitespaces. A character class allows you to create a regular expression with a pattern that…
Read more