Regular Expression
noun
say it: “REG-yuh-ler ek-SPRESH-un” /ˈrɛɡjələr ɪkˈsprɛʃən/
A pattern that describes text instead of spelling it out, such as "one or more digits", used to find, check or pull out matching parts of text.
What is a regular expression?
A regular expression is a pattern for finding or checking text, like "three digits, a dash, four digits". Python's is the re module.
import re
text = "Call 555-0199 or 555-0142"
print(re.findall(r"\d{3}-\d{4}", text)) # ['555-0199', '555-0142']
In a sentence
- “The regular expression (\d+) pulled 30 out of "about 30 min".”
- “One regular expression found every phone number in the file, however it was spaced.”
Level: Journeyman · More Python terms at this level
Updated