Python Programming Basics Practice Test: Python Regular Expressions — Flashcards | Python | FatSkills

Python Programming Basics Practice Test: Python Regular Expressions — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

Regular expressions, often shortened to regex or regexp, are a sequence of characters that define a search pattern. They can be used to search, edit, or manipulate text. Python has a built-in package called re that supports regular expressions.

Here are some of the basic metacharacters used in RegEx:
^:
Checks if the string starts with a particular word or character
$: Checks if the string ends with a particular word or character
|: Used to check either/or condition

Here are some examples of regular expressions:
\d
matches any single digit
\w matches any alphanumeric character
. matches any single character
* matches zero or more occurrences of the preceding character
+ matches one or more occurrences of the preceding character
? matches zero or one occurrence of the preceding character

1 of 49 Ready
Which module in Python supports regular expressions?
re
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password