Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Please extract all contacts from the text.
- # Valid contacts are like this - @Firstname#Familyname
- # INPUT:
- # Welcome to @ISI. If you need any help from HR you can write to
- # @Milo#Minderbinder. For any technical problems you should contact
- # @Major#Major or @Hristo#sTOIchkov. If you need any smart advises,
- # please contact @Ali#Baba or @John#Yossarian.
- # When you are sick, please stay at #Home.
- import re
- # Input from the user
- data = input()
- # RegEx pattern
- pattern = r"@[A-Z][a-z]+#[A-Z][a-z]+"
- result = re.finditer(pattern, data)
- # iterate through the valid names
- for el in result:
- print(el.group())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement