Regular Expressions in Python

Regular Expressions in Python This lesson covers Regular Expressions (re) in Python. Regular Expressions in Python are accomplished via the ‘re’ module and consist of two types of characters:
  • Ordinary: (A, a, B, b)
  • Special: “.”, “*”, ‘?”
An example of an expression in Python is /d{3}-/d{3}-/d{4}. This is a pattern which can be used to find an American phone number and consists of special characters, specifies how many of a character we are looking for. Participants also learn about Regular Expression (re) methods and Match Objects Methods:
  • compile: turns the pattern into something the regex engine can understand
  • search: scans a string for the pattern and returns to a MatchObject for the first match
  • match: only checks the beginning of the string for the pattern
  • returns subgroups of a Match Object
  • strt/reobject.end: return the string indices at which the match starts and ends
  • re: contains the regex pattern matched
This lesson also covers multithreading, which can increase speed, among its other advantages, however a disadvantage is that it’s harder to track down errors over multiple threats. Finally, participants also learn about a mutex (mutually exclusive) lock which is a means of controlling access to a resource.
Learn on the go.
The app designed for the modern cyber security professional.
Get it on Google Play Get it on the App Store

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Cybrary On The Go

Get the Cybrary app for Android for online and offline viewing of our lessons.

Get it on Google Play

Support Cybrary

Donate Here to Get This Month's Donor Badge

Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?