AutomateTheBoringStuff.Ch07 package

Submodules

AutomateTheBoringStuff.Ch07.P1_isPhoneNumber module

Is phone number

This program demonstrates isPhoneNumber() which returns True if a string is a phone number and False if not.

However, isPhoneNumber() is not very efficient because it uses if statements and for loops to check 12-segment chunks for a phone number pattern.

AutomateTheBoringStuff.Ch07.P1_isPhoneNumber.isPhoneNumber(text: str) → bool[source]

Is phone number

Function tests if given text is a phone number by checking a given text for two consecutive ‘###-` patterns followed by a ‘####’ pattern using if statements and for loops.

Parameters:text – String to check for a phone number pattern.
Returns:True if the given string is a phone number, False otherwise.
AutomateTheBoringStuff.Ch07.P1_isPhoneNumber.main()[source]

AutomateTheBoringStuff.Ch07.P2_phoneAndEmail module

Phone and email

Finds phone numbers and email addresses in the clipboard using re and pyperclip.

AutomateTheBoringStuff.Ch07.P2_phoneAndEmail.phoneRegex

Regular expression object representing a phone number pattern.

Type:re.compile
AutomateTheBoringStuff.Ch07.P2_phoneAndEmail.emailRegex

Regular expression object representing an email pattern.

Type:re.compile
AutomateTheBoringStuff.Ch07.P2_phoneAndEmail.main() → None[source]

P2_phoneAndEmail.py

Checks clipboard text for phone numbers and emails using re. If found, matches are copied to the clipboard and printed to terminal.

Returns:None. Prints and copies matches to clipboard or prints status message.

Module contents